File tree 1 file changed +11
-6
lines changed
1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -386,17 +386,22 @@ in rec {
386
386
baseUrl = last ( splitString "+" fullUrl ) ; # Get rid of "git+"
387
387
urlParts = splitString "#" baseUrl ;
388
388
url = head urlParts ;
389
- rev = last urlParts ;
390
- hasRev = length urlParts > 1 ;
391
- optionalRev = optionalAttrs hasRev { inherit rev ; } ;
392
- allRefsOrWarn = if lib . versionAtLeast __nixVersion "2.4" then {
389
+ ref = last urlParts ;
390
+ hasRef = length urlParts > 1 ;
391
+ isRev = s : ! isNull ( builtins . match "[0-9a-f]{40}" s ) ;
392
+ hasRev = hasRef && isRev ref ;
393
+ optionalRev = optionalAttrs hasRev { rev = ref ; } ;
394
+ refsOrWarn = if hasRef && ! isRev ref then {
395
+ inherit ref ;
396
+ } else if lib . versionAtLeast __nixVersion "2.4" then {
393
397
allRefs = true ;
394
398
} else
395
399
lib . warn
396
400
"Nix version is too old for allRefs = true; fetching a repository may fail if the commit is on a non-master branch"
397
401
{ } ;
398
- path = ( builtins . fetchGit
399
- ( { inherit url ; } // allRefsOrWarn // optionalRev ) ) // {
402
+ path =
403
+ ( builtins . fetchGit ( { inherit url ; } // refsOrWarn // optionalRev ) )
404
+ // {
400
405
inherit url ;
401
406
} ;
402
407
repo = filterOpamRepo { ${ name } = null ; } ( makeOpamRepo path ) ;
You can’t perform that action at this time.
0 commit comments