[bob-build-tool] Re: Howto query for source dirs on switched branch

  • From: Ralf <rhubert@xxxxxx>
  • To: bob-build-tool@xxxxxxxxxxxxx
  • Date: Fri, 21 Oct 2016 19:13:07 +0200

Hi,

I did some tests with the script today. Besides the some performance problems (it took more than 5 minutes to complete?!) this is only half of the story as Tom already mentioned. Developers probably also need to know if they have a clean working copy, if they have unpushed commits, if the commit-Id / revision / tag from the recipe matches used commitId revision / tag , ...

All of these cases can be handled by a script, but I like the idea of having a 'bob status' and 'force checkout'. Maybe I find some time to start working on this...

Ralf



On 21.10.2016 08:59, Thomas Feher wrote:

Hi,

such a feature is very interesting for us, too. At the moment we do have a script, that goes through each "workspace" directory in dev/src und performs a "git status". This way we can check if the working copy is in a dirty state or not. But we can not check if the correct revision is checked out, because that information is hidden in the recipes, and we do not want to re-implement parsing them, of course.

So I would like to see something like "bob status <recipe>" that shows me, which repository has the wrong revision checked out, so I can change those to my liking. But I see the problem that this could be hard to make SCM-agnostic.

Tom

On 10/20/2016 08:48 PM, Jan Klötzke wrote:
On Thu, Oct 20, 2016 at 07:53:01PM +0200, Ralf wrote:
> Thank's for the script. Good idea to combine query scm and query path. I'll
> test this tomorrow.
>
> What about the force-checkout? Do you think this can be a usefull feature?

It's certainly a useful feature. But I'm not sure how to implement it at
the moment, though. Internally Bob tracks for each SCM directory what
_should_ be checked out. Unless the recipe is changed Bob will consider
the directory ok. The git SCM then has some logic in the generated
checkout script to prevent the "git
pull" if some other branch is checked out.

An idea could be to extend the SCMs to check if the directory is sane
and, if not, move the affected directory into the attic. That would
imply to call git/svn/... directly from Bob. Currently the SCMs only
generate scripts...

>
> On 20.10.2016 15:02, Jan Klötzke wrote:
>> On Tue, Oct 18, 2016 at 09:24:42PM +0200, Ralf wrote:
>>> imagine the following situation:
>>>
>>> 1) bob dev myApp
>>> 2) cd dev/src/myLib/1/workspace && git checkout -b myFeatureBranch
>>> 3) write code, commit and push
>>> 4) get interrupted, do some other work and forget about 3
>>>
>>> How can I use bob to reset all src directories to the branch / tag or
>>> whatever is specified in the recipe? Or how can I query for source
>>> directories using a different branch?
>> Currently there is no option to "force" checkout. You will get a warning
>> if the checkout step encounters the wrong branch in the local working
>> copy, though.
>>
>> But there is some way to get all git checkouts with their configured
>> branches. You can use this to check if this branch is really checked
>> out. Something along the following lines should work:
>>
>>    #!/bin/bash
>>    bob query-scm -r -f git="git {package} {dir} {branch}" $1 | \
>>    grep "^git" | \
>>    while read _git package dir branch ; do
>>      base="$(bob query-path -f "{src}" $package)"
>>      [[ -n $base ]] || continue
>>      current="$(git -C $base/$dir symbolic-ref --short HEAD)"
>>      if [[ $current != $branch ]] ; then
>> echo "$base/$dir: branch '$current' checked out but '$branch' is configured"
>>      fi
>>    done
>>
>> This can certainly be optimized but it should find those switched
>> branches...
>>
>> Regards,
>> Jan
>>
>
>
>



Other related posts: