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

  • From: Jan Klötzke <jan@xxxxxxxxxxxx>
  • To: bob-build-tool@xxxxxxxxxxxxx
  • Date: Thu, 20 Oct 2016 20:48:17 +0200

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: