[opensuse-buildservice] [PATCH] [obs-service-tar_scm] add new parameter 'gitdepth'
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
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.
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@suse.de -- To unsubscribe, e-mail: opensuse-buildservice+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-buildservice+help@opensuse.org
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@suse.de
-- To unsubscribe, e-mail: opensuse-buildservice+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-buildservice+help@opensuse.org
On 2011/08/25 at 16:56:16, Adrian Schröter wrote:
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 ;)
Thanks, I tested it and submitted two small fixes, please see: https://build.opensuse.org/request/show/79803 The first of the two oneliners is a bit hackish way of "fully deepening" a shallow clone that was previously generated. I don't know any other way for doing that. Hackish in a way, that it won't fully deepen it if the commit history was HUGELY deep, that would exceed 999999999. -- Markus -- To unsubscribe, e-mail: opensuse-buildservice+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-buildservice+help@opensuse.org
Am Donnerstag, 25. August 2011, 19:34:54 schrieb Markus Lehtonen:
On 2011/08/25 at 16:56:16, Adrian Schröter wrote:
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 ;)
Thanks,
I tested it and submitted two small fixes, please see: https://build.opensuse.org/request/show/79803
The first of the two oneliners is a bit hackish way of "fully deepening" a shallow clone that was previously generated. I don't know any other way for doing that. Hackish in a way, that it won't fully deepen it if the commit history was HUGELY deep, that would exceed 999999999.
hm, just learned that no --depth means --depth=1000 actually .... Your request got accepted. thanks adrian
-- Markus -- Adrian Schroeter SUSE Linux Products GmbH email: adrian@suse.de
-- To unsubscribe, e-mail: opensuse-buildservice+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-buildservice+help@opensuse.org
participants (2)
-
Adrian Schröter
-
Markus Lehtonen