Mailinglist Archive: opensuse-buildservice (256 mails)

< Previous Next >
Re: [opensuse-buildservice] [PATCH] [obs-service-tar_scm] add new parameter 'gitdepth'
  • From: Adrian Schröter <adrian@xxxxxxx>
  • Date: Thu, 25 Aug 2011 15:56:16 +0200
  • Message-id: <10955272.hmuu8X9TlV@scherben>
Am Donnerstag, 25. August 2011, 15:53:38 schrieb Adrian Schröter:
Am Donnerstag, 25. August 2011, 13:54:20 schrieb Markus Lehtonen:
Add's a new parameter, 'gitdepth' that can be used to define the
"history depth" of the git clone/pull. Default behavior stays the
same, i.e., tar_scm creates a shallow clone with depth=1.

Hi, I submitted a slightly different version, which allows us to use this
parameter also for other SCM's when they support it.

I forgot to say, please test my code. I haven't ;)

sorry
adrian

Special value "full" can be used to create full-depth clones/pulls that
fetches the complete history.
---

tar_scm | 13 +++++++++++--
tar_scm.service | 3 +++
2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/tar_scm b/tar_scm
index 5ca91ff..da7a9fe 100644
--- a/tar_scm
+++ b/tar_scm
@@ -18,6 +18,7 @@ MYPREFIX=""

MYFILENAME=""
MYREVISION=""
MYPACKAGEMETA=""

+MYGITDEPTH="1"

while test $# -gt 0; do

case $1 in

@@ -61,6 +62,10 @@ while test $# -gt 0; do

MYOUTDIR="$2"
shift

;;

+ *-gitdepth)
+ MYGITDEPTH="$2"
+ shift
+ ;;

*)

echo Unknown parameter $1.
echo 'Usage: tar_scm --scm $SCM --url $URL --outdir $OUT'

@@ -88,6 +93,10 @@ if [ -z "$MYOUTDIR" ]; then

echo "ERROR: no output directory is given via --outdir parameter!"
exit 1

fi

+if [ "$MYGITDEPTH" == "full" ]; then
+ # A bit hackish way of fully deepening a clone / getting a non-shallow
clone + MYGITDEPTH=999999999
+fi

SRCDIR=$(pwd)
cd "$MYOUTDIR"

@@ -166,7 +175,7 @@ elif [ "$MYSCM" == "git" ]; then

# update existing content for speed/bandwidth reasons
cd "$TAR_DIRECTORY"
OLDVERSION=`git show --pretty=%at | head -n 1`

- git pull || exit 1
+ git pull --depth="$MYGITDEPTH" || exit 1

if [ -n "$MYREVISION" ]; then

git checkout "$MYREVISION" || exit 1

fi

@@ -180,7 +189,7 @@ elif [ "$MYSCM" == "git" ]; then

mv "$TAR_DIRECTORY" "${FILE}" || exit 1

else

# new checkout

- git clone --depth 1 "$MYURL" "${FILE}" || exit 1
+ git clone --depth "$MYGITDEPTH" "$MYURL" "${FILE}" || exit 1

if [ -n "$MYREVISION" ]; then

cd "$FILE"
git checkout "$MYREVISION" || exit 1

diff --git a/tar_scm.service b/tar_scm.service
index 844f629..d1064a3 100644
--- a/tar_scm.service
+++ b/tar_scm.service
@@ -35,5 +35,8 @@

<description>Package the meta data of SCM to allow the user or OBS to

update after un-tar</description> <allowedvalue>yes</allowedvalue>

</parameter>

+ <parameter name="gitdepth">
+ <description>Git history depth. Special value "full" clones/pulls
full
history. Only valid if SCM git is used.</description> + </parameter>

</service>
--
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 >