Mailinglist Archive: opensuse-buildservice (327 mails)

< Previous Next >
Re: [opensuse-buildservice] [PATCH] checkout git branch with tar_scm source servce
On Monday 11 April 2011 08:44:30 Sascha Peilicke wrote:
On Saturday 09 April 2011 15:46:58 Will Stephenson wrote:
The following patch enables tar_scm to checkout a specified git branch
instead of HEAD.

For svn, the option is meaningless as the branch is part of the URL. I
don't know anything about Hg, so can't say if the option is used there.
For now I have marked it (git only).

Any comments?

No diff attached?

Whoops - guess I should add 'patch' to the strings that trigger an attachment
warning from kmail.

Will
--
Will Stephenson, KDE Developer, openSUSE Boosters Team
SUSE LINUX Products GmbH - Nürnberg - AG Nürnberg - HRB 16746 - GF: Markus Rex
--- /usr/lib/obs/service/tar_scm 2011-03-31 16:16:10.000000000 +0200
+++ tar_scm 2011-04-09 15:34:26.094084184 +0200
@@ -17,6 +17,7 @@
MYPREFIX=""
MYFILENAME=""
MYREVISION=""
+MYBRANCH=""

while test $# -gt 0; do
case $1 in
@@ -56,6 +57,10 @@
MYOUTDIR="$2"
shift
;;
+ *-branch)
+ MYBRANCH="$2"
+ shift
+ ;;
*)
echo Unknown parameter $1.
echo 'Usage: tar_scm --scm $SCM --url $URL --outdir $OUT'
@@ -159,6 +164,9 @@
cd "$TAR_DIRECTORY"
OLDVERSION=`git show --pretty=%at | head -n 1`
git pull || exit 1
+ if [ -n "$MYBRANCH" ]; then
+ git checkout -B "$MYBRANCH" || exit 1
+ fi
if [ -n "$MYREVISION" ]; then
git checkout "$MYREVISION" || exit 1
fi
@@ -172,7 +180,12 @@
mv "$TAR_DIRECTORY" "${FILE}" || exit 1
else
# new checkout
- git clone --depth 1 "$MYURL" "${FILE}" || exit 1
+ # clone any requested branch
+ if [ -n "$MYBRANCH" ]; then
+ git clone --depth 1 -b "${MYBRANCH}" "$MYURL" "${FILE}" || exit 1
+ else
+ git clone --depth 1 "$MYURL" "${FILE}" || exit 1
+ fi
if [ -n "$MYREVISION" ]; then
cd "$FILE"
git checkout "$MYREVISION" || exit 1
--- /usr/lib/obs/service/tar_scm.service 2011-03-31 16:16:10.000000000
+0200
+++ tar_scm.service 2011-04-09 15:36:09.448990648 +0200
@@ -30,5 +30,8 @@
<parameter name="version">
<description>version to be used in tar</description>
</parameter>
+ <parameter name="branch">
+ <description>(git only) branch to be used in tar</description>
+ </parameter>
</service>

< Previous Next >
Follow Ups