Skip to content

Commit 7e9fdb1

Browse files
authored
Merge pull request #50 from expipiplus1/joe-refs
Pass `--heads --tags` to `git ls-remote` to avoid fetching remote refs
2 parents 52d41bd + 1b9787e commit 7e9fdb1

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

Diff for: CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
## WIP
44

5+
## [0.2.5] - 2020-11-14
6+
7+
- Pass `--heads --tags` to `git ls-remote` to avoid fetching remote
8+
refs. Don't pass when the revision begins with `refs`
9+
510
## [0.2.4] - 2020-11-11
611

712
- Add --dry-run option

Diff for: package.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: update-nix-fetchgit
2-
version: "0.2.4"
2+
version: "0.2.5"
33
synopsis: A program to update fetchgit values in Nix expressions
44
description: |
55
This command-line utility is meant to be used by people maintaining Nix

Diff for: src/Update/Nix/FetchGit/Prefetch.hs

+13-6
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,23 @@ getGitRevision repo revision = do
103103
| otherwise -> pure hash
104104
Nothing -> refute1 $ NoSuchRef (unRevision revision)
105105

106-
-- | Run git ls-remote --sort=-v:refname and return the first match if any
106+
-- | Run git ls-remote --heads --tags --sort=-v:refname and return the first
107+
-- match if any. Use '--heads --tags' if the revision doesn't start with
108+
-- 'refs/' to avoid getting 'remote' refs.
107109
gitLsRemotes :: Text -> Revision -> M (Maybe (Text, Text))
108110
gitLsRemotes repo revision = do
111+
let headsTags = if T.isPrefixOf "refs/" (unRevision revision)
112+
then []
113+
else ["--heads", "--tags"]
109114
(exitCode, nsStdout, nsStderr) <- liftIO $ readProcessWithExitCode
110115
"git"
111-
[ "ls-remote"
112-
, "--sort=-v:refname"
113-
, T.unpack repo
114-
, T.unpack (unRevision revision)
115-
]
116+
( [ "ls-remote"
117+
, "--sort=-v:refname"
118+
, T.unpack repo
119+
, T.unpack (unRevision revision)
120+
]
121+
<> headsTags
122+
)
116123
""
117124
case exitCode of
118125
ExitFailure e -> refute1 (NixPrefetchGitFailed e (pack nsStderr))

Diff for: update-nix-fetchgit.cabal

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cabal-version: 1.12
55
-- see: https://github.com/sol/hpack
66

77
name: update-nix-fetchgit
8-
version: 0.2.4
8+
version: 0.2.5
99
synopsis: A program to update fetchgit values in Nix expressions
1010
description: This command-line utility is meant to be used by people maintaining Nix
1111
expressions that fetch files from Git repositories. It automates the process

0 commit comments

Comments
 (0)