aboutsummaryrefslogtreecommitdiffstats
path: root/pkgs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2020-07-02 19:44:56 +0200
committerGitHub <noreply@github.com>2020-07-02 19:44:56 +0200
commit5ea125514e48c630120fbb6a44e9ae0c7932a123 (patch)
tree6da01501ec47bade5a259d00c10f6f5a1c9c8c22 /pkgs
parent3e731035ed44659624e6d00bbb35570f2b8811fd (diff)
parent54eb1c89cf66ab882427c0d714f5c9a498687326 (diff)
Merge pull request #21 from elohmeier/git-shallowv1.23.0
add shallow option to git source type
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/populate/default.nix18
1 files changed, 15 insertions, 3 deletions
diff --git a/pkgs/populate/default.nix b/pkgs/populate/default.nix
index 40c37e3..bac1432 100644
--- a/pkgs/populate/default.nix
+++ b/pkgs/populate/default.nix
@@ -53,7 +53,11 @@ let
pop.git = target: source: runShell target /* sh */ ''
set -efu
if ! test -e ${quote target.path}; then
- git clone --recurse-submodules ${quote source.url} ${quote target.path}
+ ${if source.shallow then /* sh */ ''
+ git init ${quote target.path}
+ '' else /* sh */ ''
+ git clone --recurse-submodules ${quote source.url} ${quote target.path}
+ ''}
fi
cd ${quote target.path}
if ! url=$(git config remote.origin.url); then
@@ -67,10 +71,18 @@ let
if ! test "$(git log --format=%H -1)" = "$hash"; then
${if source.fetchAlways then /* sh */ ''
- git fetch origin
+ ${if source.shallow then /* sh */ ''
+ git fetch --depth=1 origin "$hash"
+ '' else /* sh */ ''
+ git fetch origin
+ ''}
'' else /* sh */ ''
if ! git log -1 "$hash" >/dev/null 2>&1; then
- git fetch origin
+ ${if source.shallow then /* sh */ ''
+ git fetch --depth=1 origin "$hash"
+ '' else /* sh */ ''
+ git fetch origin
+ ''}
fi
''}
git reset --hard "$hash" >&2