libnetwork.lib.in: git sources: simple support for checking out at a specific commit by supporting the syntax: --git-branch branch[@commit_id]

This commit is contained in:
Silvan Calarco 2019-10-27 15:18:42 +01:00
parent 08bfa59a98
commit 38a689e2de
3 changed files with 18 additions and 4 deletions

View File

@ -947,6 +947,7 @@ function git.create_tarball() {
# see: http://bardofschool.blogspot.fr/2008/11/use-git-behind-proxy.html
local proxy proxy_user
local git_branch
local git_commit
local preserve_dot_git=0
local pck_version
@ -963,7 +964,14 @@ function git.create_tarball() {
;;
--git-branch)
git_branch="$2"; shift
if [ "${git_branch/@*}" != "${git_branch}" ]; then
git_commit="${git_branch/*@}"
git_branch="${git_branch/@*}"
fi
notify.debug "$FUNCNAME: git_branch = \"$git_branch\""
if [ "${git_commit}" ]; then
notify.debug "$FUNCNAME: git_commit = \"$git_commit\""
fi
;;
--preserve-dot-git)
preserve_dot_git="$2"; shift
@ -1016,7 +1024,7 @@ not the expected package version"" (${NOTE}${today}git${NORM})..."
notify.note \
"${NOTE}"$"cloning git repository""\
<$git_repository> ${git_branch:+($git_branch)}${NORM}""..."
if [ "$preserve_dot_git" = "0" -a "${git_repository:0:4}" != "http" ]; then
if [ "$preserve_dot_git" = "0" -a "${git_repository:0:4}" != "http" -a ! "${git_commit}" ]; then
notify.debug "$FUNCNAME: git clone --recursive --depth=1 ${git_branch:+-b $git_branch} \"$git_repository\""
git clone --recursive --depth=1 ${git_branch:+-b $git_branch} "$git_repository"
else
@ -1030,6 +1038,12 @@ not the expected package version"" (${NOTE}${today}git${NORM})..."
pck_tarball="$(find -mindepth 1 -maxdepth 1 -type d -printf "%f")"
if [ "${git_commit}" ]; then
cd ${pck_tarball}
git checkout ${git_commit}
cd ..
fi
if [ "$preserve_dot_git" = "0" ]; then
# remove git files
rm -fr $pck_tarball/.git

View File

@ -124,7 +124,7 @@ function usage() {
"$"Override packager full name""
--packager-email
"$"Override packager email""
--git-branch "$"Specify a git branch""
--git-branch "$"Specify a git branch or tag and (optionally) a commit by appending @commit_id""
--preserve-dot-git "$"Do not remove git files""
--colors "$"Select the theme to be used for the colorized output""
-C, --config "$"Use an alternate user configuration file"" <conf_file>""

View File

@ -862,8 +862,8 @@ msgstr "specfile per applicazioni web"
msgid "Redirect the output to the file <outfile>"
msgstr "Redirige lo standard output sul file <outfile>"
msgid "Specify a git branch"
msgstr "Specifica un branch git"
msgid "Specify a git branch or tag and (optionally) a commit by appending @commit_id"
msgstr "Specifica un branch o un tag git e (opzionalmente) un commit aggiungendo @commit_id"
msgid "Do not remove git files"
msgstr "Non rimuove i file git"