Skip to content

Commit

Permalink
fetchgitlab: add tag argument
Browse files Browse the repository at this point in the history
  • Loading branch information
Bot-wxt1221 committed Dec 24, 2024
1 parent ef0cdab commit 4616db6
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions pkgs/build-support/fetchgitlab/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ lib.makeOverridable (
{
owner,
repo,
rev,
rev ? null,
tag ? null,
protocol ? "https",
domain ? "gitlab.com",
name ? "source",
Expand All @@ -22,6 +23,12 @@ lib.makeOverridable (
... # For hash agility
}@args:

assert (
lib.assertMsg (lib.xor (tag == null) (
rev == null
)) "fetchFromGitLab requires one of either `rev` or `tag` to be provided (not both)."
);

let
slug = lib.concatStringsSep "/" (
(lib.optional (group != null) group)
Expand All @@ -31,14 +38,17 @@ lib.makeOverridable (
]
);
escapedSlug = lib.replaceStrings [ "." "/" ] [ "%2E" "%2F" ] slug;
escapedRev = lib.replaceStrings [ "+" "%" "/" ] [ "%2B" "%25" "%2F" ] rev;
escapedRev = lib.replaceStrings [ "+" "%" "/" ] [ "%2B" "%25" "%2F" ] (
if tag != null then "refs/tags/" + tag else rev
);
passthruAttrs = removeAttrs args [
"protocol"
"domain"
"owner"
"group"
"repo"
"rev"
"tag"
"fetchSubmodules"
"forceFetchGit"
"leaveDotGit"
Expand All @@ -58,6 +68,7 @@ lib.makeOverridable (
inherit
rev
deepClone
tag
fetchSubmodules
sparseCheckout
leaveDotGit
Expand All @@ -82,6 +93,11 @@ lib.makeOverridable (
fetcher fetcherArgs
// {
meta.homepage = "${protocol}://${domain}/${slug}/";
inherit rev owner repo;
inherit
tag
rev
owner
repo
;
}
)

0 comments on commit 4616db6

Please sign in to comment.