Skip to content

Commit 4616db6

Browse files
committed
fetchgitlab: add tag argument
1 parent ef0cdab commit 4616db6

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

pkgs/build-support/fetchgitlab/default.nix

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ lib.makeOverridable (
99
{
1010
owner,
1111
repo,
12-
rev,
12+
rev ? null,
13+
tag ? null,
1314
protocol ? "https",
1415
domain ? "gitlab.com",
1516
name ? "source",
@@ -22,6 +23,12 @@ lib.makeOverridable (
2223
... # For hash agility
2324
}@args:
2425

26+
assert (
27+
lib.assertMsg (lib.xor (tag == null) (
28+
rev == null
29+
)) "fetchFromGitLab requires one of either `rev` or `tag` to be provided (not both)."
30+
);
31+
2532
let
2633
slug = lib.concatStringsSep "/" (
2734
(lib.optional (group != null) group)
@@ -31,14 +38,17 @@ lib.makeOverridable (
3138
]
3239
);
3340
escapedSlug = lib.replaceStrings [ "." "/" ] [ "%2E" "%2F" ] slug;
34-
escapedRev = lib.replaceStrings [ "+" "%" "/" ] [ "%2B" "%25" "%2F" ] rev;
41+
escapedRev = lib.replaceStrings [ "+" "%" "/" ] [ "%2B" "%25" "%2F" ] (
42+
if tag != null then "refs/tags/" + tag else rev
43+
);
3544
passthruAttrs = removeAttrs args [
3645
"protocol"
3746
"domain"
3847
"owner"
3948
"group"
4049
"repo"
4150
"rev"
51+
"tag"
4252
"fetchSubmodules"
4353
"forceFetchGit"
4454
"leaveDotGit"
@@ -58,6 +68,7 @@ lib.makeOverridable (
5868
inherit
5969
rev
6070
deepClone
71+
tag
6172
fetchSubmodules
6273
sparseCheckout
6374
leaveDotGit
@@ -82,6 +93,11 @@ lib.makeOverridable (
8293
fetcher fetcherArgs
8394
// {
8495
meta.homepage = "${protocol}://${domain}/${slug}/";
85-
inherit rev owner repo;
96+
inherit
97+
tag
98+
rev
99+
owner
100+
repo
101+
;
86102
}
87103
)

0 commit comments

Comments
 (0)