Mailinglist Archive: opensuse-buildservice (256 mails)

< Previous Next >
Re: [opensuse-buildservice] [PATCH 1/3] [obs-service-tar_scm] Checkout master before git update
  • From: Adrian Schröter <adrian@xxxxxxx>
  • Date: Mon, 29 Aug 2011 14:06:06 +0200
  • Message-id: <1389545.ndIgrI2rdm@scherben>
Am Freitag, 26. August 2011, 12:42:06 schrieb Markus Lehtonen:
On 2011/08/26 at 09:36:52, Adrian Schröter wrote:
Am Freitag, 26. August 2011, 08:43:05 schrieb Markus Lehtonen:
Check out master branch before doing git update so that merge

succeeds

and the files are updated.

Would this still work when you actually want to checkout a non-master
branch ?
eg. when MYREVISION is 2.3 for build-service repository ?

Yes it should. My patch just tries to make sure that the merge in pull
succeeds. This matters if no revision is specified in _service - i.e. always
use the latest git head in the tarball. Problems arise e.g. if you first
define MYREVISION 2.3 (which "checkouts" 2.3 in to a non-branch), and then
later, want to get latest HEAD and remove MYREVISION. In this case the
merge in git pull would fail and you'd still get version 2.3 from that
non-branch that was previously checked out.

ic

We may should do

fetch
checkout
merge

here instead ?

Hmm, shouldn't matter, AFAIU. I see one potential problem, though. If the
git HEAD on the remote server points to something else than
refs/heads/master, let's say refs/heads/upstream. Then git clone would
create branch 'upstream' and there'd be no master branch and checkout would
fail. I don't then know how to nicely checkout the "default branch", i.e.
how to determine the name of that branch. Something like?
git fetch
DEFAULTBRANCH=`sed s'!^ref.*/!!' .git/refs/remotes/origin/HEAD`
git checkout $DEFAULTBRANCH
git merge

What do you think?

Hm, I would avoid to handle the DEFAULTBRANCH at all. It is just important for
us to handle OUR branch. So my code would be this:

if [ -n "$MYREVISION" ]; then
git fetch $MYGITARGS || exit 1
git checkout "$MYREVISION" || exit 1
git merge "origin/$MYREVISION" HEAD || exit 1
else
git pull $MYGITARGS || exit 1
fi

and leave it to "git pull" to handle the default branch if needed.
Does this make sense ?

bye
adrian

--
Adrian Schroeter
SUSE Linux Products GmbH
email: adrian@xxxxxxx

--
To unsubscribe, e-mail: opensuse-buildservice+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse-buildservice+help@xxxxxxxxxxxx

< Previous Next >
Follow Ups