Mailinglist Archive: opensuse-buildservice (256 mails)

< Previous Next >
RE: [opensuse-buildservice] [PATCH 1/3] [obs-service-tar_scm] Checkout master before git update
  • From: "Markus Lehtonen" <markus.lehtonen@xxxxxxxxxxxxxxx>
  • Date: Fri, 26 Aug 2011 12:42:06 +0300
  • Message-id: <000901cc63d4$6c0d9db0$4428d910$@lehtonen@linux.intel.com>
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.


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?


---
tar_scm | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/tar_scm b/tar_scm
index 257b794..34b50f9 100644
--- a/tar_scm
+++ b/tar_scm
@@ -175,6 +175,8 @@ elif [ "$MYSCM" == "git" ]; then
# update existing content for speed/bandwidth reasons
cd "$TAR_DIRECTORY"
OLDVERSION=`git show --pretty=%at | head -n 1`
+ # switch to default branch so that merge succeeds
+ git checkout master || exit 1
git pull $MYGITARGS || exit 1
if [ -n "$MYREVISION" ]; then
git checkout "$MYREVISION" || exit 1

--
Markus

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

< Previous Next >