Skip to content

Commit 6658d9a

Browse files
author
Michael Prokop
committed
Support git source options for packages in '3.0 (git)' format (PR #125)
Provide a way to limit the size of the git clone for git format packages, this is very usefull for packages with a huge commit history. Thanks: Franco (nextime) Lanza <[email protected]> for the initial patch
1 parent 220f87e commit 6658d9a

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

scripts/generate-git-snapshot

+28
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,33 @@ quilt_cleanup() {
351351
rm -rf .pc
352352
}
353353

354+
git_source_options() {
355+
if [ -n "${SKIP_GIT_SOURCE_OPTIONS:-}" ] ; then
356+
echo "*** Skipping git_source_options as requested via SKIP_GIT_SOURCE_OPTIONS ***"
357+
return 0
358+
fi
359+
360+
local file="debian/source/options"
361+
if [ -f "${file}" ]; then
362+
local opt_depth=$(git config --file "${file}" --get git-depth 2>&- || true)
363+
local opt_ref=$(git config --file "${file}" --get git-ref 2>&- || true)
364+
fi
365+
366+
if [ -n "${GIT_DEPTH:-}" ]; then
367+
echo "*** GIT_DEPTH is set, setting git depth to ${GIT_DEPTH} ***"
368+
DBP_EXTRA_OPTS="${DBP_EXTRA_OPTS:-} --source-option=--git-depth=${GIT_DEPTH}"
369+
elif [ -n "${opt_depth:-}" ]; then
370+
echo "*** Using source depth of '$opt_depth' as defined in debian/source/options ***"
371+
fi
372+
373+
if [ -n "${GIT_REF:-}" ] ; then
374+
echo "*** GIT_REF is set, setting git ref to ${GIT_REF} ***"
375+
DBP_EXTRA_OPTS="${DBP_EXTRA_OPTS:-} --source-option=--git-ref=${GIT_REF}"
376+
elif [ -n "${opt_ref:-}" ]; then
377+
echo "*** Using git ref '$opt_ref' as defined in debian/source/options ***"
378+
fi
379+
}
380+
354381
source_format_opts() {
355382
if ! [ -f "debian/source/format" ] ; then
356383
echo '*** WARNING: Source format is not specified in debian/source/format! ***'
@@ -366,6 +393,7 @@ source_format_opts() {
366393
;;
367394
'3.0 (git)')
368395
echo "*** Source format detected as 3.0 (git) ***"
396+
git_source_options
369397
PRISTINE_TAR=false
370398
SKIP_QUILT_CLEANUP=true
371399
IGNORE_GIT_BUILDPACKAGE=true

0 commit comments

Comments
 (0)