Commit Graph

117 Commits

Author SHA1 Message Date
Scott Worley
697bba9892 fetchgit: Support fetching signed tags over dumb http transport 2024-04-22 02:16:02 +02:00
linsui
1ed37ac9f3 fetchgit: set http.proxy globally for submodules
git config in the repo doesn't work for submodules
2024-03-21 19:14:00 +08:00
SharzyL
b186e2d76e nix-prefetch-git: make it quiet
Some programs (e.g. nvfetcher) parse the output of nix-prefetch-git as
JSON. However, there is a pushd/popd command in nix-prefetch-git that
outputs the directory name, breaking the structure of the result JSON.
We suppressed it with `>/dev/null`.

Passingly fixes a mixuse of tab and spaces.
2023-11-12 15:20:16 +01:00
Elliot Cameron
3a99d1b642 nix-prefetch-git: respect NETRC
This script needs to support being run both as part of a `fetchgit`
derivation and as a standalone, command-line tool.

The use of `$NIX_BUILD_TOP` only works when used in `fetchgit` but not when
invoked as a standalone tool. Instead we try to respect `$NETRC` so that
the command-line invocation behaves more like standard tools and the
`fetchgit` derivation can explicitly set `$NETRC` when `netrcPhase` is used
to avoid all ambiguity.
2023-11-11 19:34:54 +01:00
Shogo Takata
d6e1c7cae6
fetchgit: shallow clone for submodules (#254172) 2023-11-09 04:32:13 +02:00
K900
fa40d6457a nix-prefetch-git: download submodules with --progress 2023-11-05 20:49:03 +03:00
Domen Kožar
3c6cf39435
Merge pull request #249733 from Aleksanaa/nix-prefetch-git
nix-prefetch-git: fix make_deterministic_repo in submodules
2023-10-16 11:12:11 +01:00
Sandro Jäckel
d09cd1d7d1 fetchgit: use $NIX_BUILD_TOP instead of hardcoding /build/
Co-authored-by: Bjørn Forsman <133602+bjornfor@users.noreply.github.com>
2023-10-08 00:10:59 +02:00
Sandro Jäckel
025a028c47 fetchgit: fix private fetching via netrc
This fixes a regression introduced in https://github.com/NixOS/nixpkgs/pull/256628
which broke fetching with private = true through a netrc file.
Tested locally with a really special github enterprise.
2023-10-05 13:54:00 +00:00
Alyssa Ross
7d40fbbc04
nix-prefetch-git: ignore global and user git config
nix-prefetch-git is either run as part of a build, usually sandboxed,
or outside a build, unsandboxed, to prefetch something that will later
be used in a build.  It's important that the latter use produces
hashes that can be reproduced by the former.

One way that they can differ is if the user's git config does
something that changes the result of git clone.  I ran into this,
because my global git config automatically enables git-lfs, whereas
nix-prefetch-git otherwise only uses git-lfs if specifically
requested.  This led to very confusing hash mismatches.
2023-09-22 06:59:40 +00:00
Silvan Mosberger
7cbc8215fd
Merge pull request #252865 from emily-is-my-username/fix/fetchgit-deepclone
`fetchgit`: don't shallow clone if `deepClone` is requested
2023-09-06 14:08:06 +02:00
aleksana
981754aba8 nix-prefetch-git: fix make_deterministic_repo in submodules 2023-08-31 18:25:06 +08:00
PedroHLC ☭
0142902fc4
nix-prefetch-git: add sri-hash to output 2023-07-09 14:46:58 -03:00
Emily
ad94541662 fetchgit: don't shallow clone if deepClone is requested
fixes: https://github.com/NixOS/nixpkgs/issues/179788
2023-07-01 00:10:26 +02:00
Mario Rodas
922d55bf2d fetchgit: add a default NIX_BUILD_CORES variable
NIX_BUILD_CORES might not be defined at runtime, so the command would
fail.
2023-06-24 04:20:00 +00:00
Domen Kožar
4f72b6af8b fetchgit: fetch submodules in parallel 2023-06-20 10:36:10 +01:00
fetsorn
29f3903f62 nix-prefetch-git: fix typo 2023-05-31 04:00:32 +04:00
Ryan Hendrickson
0f6712d45a nix-prefetch-git: redirect git lfs to stderr 2023-05-21 09:05:49 +02:00
Winter
dbd18a63a7 fetchgit: allow disabling cone mode for sparse checkouts, fix test 2022-08-14 23:03:07 +02:00
Sebastian Jordan
783e2ef46e Revert "nix-prefetch-git: Fix inconsistency with fetchgit regarding deepClone"
This reverts commit 1dfaad73ed.
2022-06-30 11:52:36 +00:00
Sebastian Jordan
1dfaad73ed nix-prefetch-git: Fix inconsistency with fetchgit regarding deepClone
The fetchgit function in nixpkgs sets the leaveDotGit argument to true
if deepClone is set to true. nix-prefetch-git did behave differently. It
would not assume --leave-dotGit if --deepClone is specified. With this
change the inconsistency is addressed by assuming --leave-dotGit if
--deepClone is specified.
2022-06-14 00:23:16 +02:00
Zhong Jianxin
d03a07d5a7 fetchgit: Support sparse checkout
This allow git checkout small parts of a large repo, and avoid fetching
unnecessary blobs from server.
2022-01-24 11:23:56 +08:00
Tomas Bravo
80ab168c4a nix-prefetch-git: fix incorrect mktemp usage 2021-12-22 16:45:18 +01:00
Sandro Jäckel
6f53c06748 fetchgit: add support for netrc file through impure NIX_GIT_SSL_CAINFO env 2021-09-28 15:00:11 +02:00
Bjørn Forsman
9bd51f0db9 nix-prefetch-git: add fetchLFS flag to the JSON output
Similarly to the other flags (e.g. fetchSubmodules).
2021-08-28 10:14:48 +02:00
Bjørn Forsman
f43829a1d8 nix-prefetch-git: provide fallback for $TMPDIR
$TMPDIR is not set by default in NixOS (nor Ubuntu), so without this
change nix-prefetch-git fails when using git-lfs.
2021-08-28 10:14:48 +02:00
Atemu
11df41199b nix-prefetch-git: don't fetch everything when given a hash
It's hugely inefficient as we can't use shallow cloning (--depth=1).

This has been tested and adapted for quite a few hosts fetchgit is used on in
Nixpkgs. For those where fetching the hash directly doesn't work (most notably
git.savannah.gnu.org), we simply fall back to the old method.
2021-07-12 20:50:52 +02:00
Bjørn Forsman
2e8f6e0d93 fetchgit: document --fetch-lfs flag
Fixes: 74128561 ("fetchgit: add lfs support")
2021-05-07 15:38:54 -07:00
taku0
a964d7094a
Merge pull request #104714 from codedownio/tree-hashes
fetchgit: support passing tree hashes as "rev"
2021-02-20 15:22:57 +09:00
Michael Weiss
2aadb9a53d
nix-prefetch-git: Run git-init with --initial-branch=master
The reason for this change is simply to avoid the following messages
that are unnecessary and can be confusing (and these messages will be
repeated for each submodule):
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint:   git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint:   git branch -m <name>

With this change the behaviour remains unchanged (apart from the
suppressed "warning" in the console output of course) and therefore this
doesn't cause any hashes to change and by default nix-prefetch-git uses
the "fetchgit" branch anyway (branchName can be set to override the
default):
Switched to a new branch 'fetchgit'

For that reason the initial branch name doesn't matter anyway and since
we're not relying on / hardcoding "master" we could simply switch to
"main" (which seems most common nowadays). See [0] for more details on
why this wouldn't break anything.
However, since the initial branch name doesn't matter and to avoid any
additional risks it was "decided" to keep using "master" (s. #113313).

[0]: https://github.com/NixOS/nixpkgs/pull/113313#issuecomment-780589516
2021-02-18 11:34:34 +01:00
Tom McLaughlin
6779902b32 fetchgit: support passing tree hashes as "rev" 2021-02-13 22:12:08 -08:00
Jonathan Ringer
741285611f fetchgit: add lfs support 2021-01-11 09:41:06 -08:00
Jörg Thalheim
2fb5dac372 nix-prefetch-git: also add store path to json output 2020-05-04 17:43:29 +05:30
Benjamin Hipple
259f3b3b68
Revert "fetchzip, fetchgit: cleanup handling of optional features and whitespace" 2020-03-26 00:35:40 -04:00
Benjamin Hipple
368ea2eb5e
Merge pull request #79581 from bhipple/feature/fetcher-whitespace-clean
fetchzip, fetchgit: cleanup handling of optional features and whitespace
2020-03-26 00:15:24 -04:00
Jan Tojnar
28faf5bc86
nix-prefetch-git: Fix output mangling
`git repack` and `git gc` sometimes print “Nothing new to pack.”
to stdout, which breaks redirecting output to JSON file.

Let’s move the stdout of all git calls where it is not used to stderr
so that we still receive the info but it does not pollute our output.
2020-02-14 22:15:36 +01:00
Jan Tojnar
f19a101a73
nix-prefetch-git: report deepClone & leaveDotGit
Just like in be30ba8e0e
we want `fetchgit (builtins.fromJSON (builtins.readFile ./src.json))` to work.
2020-02-14 06:05:43 +01:00
Benjamin Hipple
caff183402 fetchzip, fetchgit: cleanup handling of optional features and whitespace
No intended functional difference, just trying to polish to make this easier to
extend and more aligned with other nix conventions.
2020-02-08 21:51:46 -05:00
Dima
df7f3e0f98 nix-prefetch-git: list --branch-name in help
Listing the option and brief explanation.
Addresses: https://github.com/NixOS/nixpkgs/issues/74182
2019-11-26 20:43:23 +01:00
Silvan Mosberger
89636b9a5e
nix-prefetch-git: Remove some pack file non-determinism 2019-08-31 01:16:50 +02:00
Matthew Bauer
c08cdfa781
Merge pull request #54543 from thefloweringash/git-prefetch-errors
nix-prefetch-git: propagate errors under --quiet
2019-06-18 11:20:28 -04:00
Andreas Rammhold
46f84adc0c
nix-prefetch-git: add -h as shortcut for --help to improve quality of life
Especially as a new user it is a much better experience to receive a
proper help response to `-h`. Currently passing `-h` will cause some
runtime error with the `git remote` error help being shown. Not very
helpful.

It doesn't hurt to be a bit more user friendly in this case.
2019-05-03 23:56:40 +02:00
Andrew Childs
597d6d2bcd nix-prefetch-git: propagate errors under --quiet 2019-01-25 01:52:26 +09:00
Craig Younkins
8b12b17df3
treewide: Fix broken Gmane URLs 2018-12-25 22:34:55 -05:00
Guillaume Maudoux
ea23a1ed4e fetchgit: adapt regex to git 2.18.0 2018-06-28 07:01:14 -05:00
Tim Cuthbertson
c5454933a1 nix-prefetch-git: fix output fetchSubmodules property 2018-06-17 21:19:27 +10:00
Lionello Lunesu
9fe26eed9e nix-prefetch-git: fix handling of submodules with spaces
The script would parse the output of `git submodule status` but
didn't handle paths with spaces in them. This would result in the
following error when trying to determine the URL of the submodule:

error: key does not contain a section: .url
2018-05-04 23:16:51 +08:00
Will Dietz
0e95bed017 nix-prefetch-git: fix extraction of submodule hashes on latest git
Summary:

According to git-submodule manpage,
"git submodule status" prefixes the hash with a '-' if it is not
initialized, and other chars in other circumstances.
(this is consistent on the various git versions tested)

nix-prefetch-git runs "git submodule init" which does you'd think,
but apparently despite this earlier versions of git before 2.16
would still give the hash the '-' suffix.
In particular this is the behavior when using 2.15 and 2.14.1
from the nixos-17.09 and nixos-17.03 channels respectively.

The script then used awk to drop the first char of the first field
which does the wrong thing when there is no prefix emitted:
while there is a space character before the hash, this is not
part of the field and so we ended up eating the first character
of the hash.

To fix this in a way that also works with the previous behavior,
this commit instead uses awk to grab the hash field
and uses tr to delete any '-' chars should they be present.

This seems to work in my testing, and for example can now
successfully fetch the source for "nginxModules.brotli"
where previously it would generate an error:

fatal: '22564a95d9ab58865a096b8d9f7324ea5f2e03e' is not a commit and a branch 'fetchgit' cannot be created from it

(we dropped a '2' from the beginning of the hash)
2018-01-24 20:18:59 +02:00
Vaibhav Sagar
376f7aa761
Update nix-prefetch-git
s/understand/understood/
2017-10-29 12:02:26 +08:00
Vladimír Čunát
9e1c7ddaae
Merge branch 'master' into staging 2017-07-05 09:53:53 +02:00