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. 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> -- 1.7.3.4 -- To unsubscribe, e-mail: opensuse-buildservice+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-buildservice+help@opensuse.org