Commit Graph

66 Commits

Author SHA1 Message Date
Tobias Geerinckx-Rice 5d10644371
git: Make better use of the better progress bar.
Commit 189525412e introduced
‘high-resolution’ Unicode progress bars, but these require more granular
calls to reach their full potential.

* guix/git.scm (show-progress): Derive the number of PROGRESS-BAR
updates from its maximum resolution, rather than hard-coding 100.
2023-02-19 01:00:06 +01:00
Tobias Geerinckx-Rice 98e2a15b1e
git: Factor out INDEXER-PROGRESS-TOTAL-OBJECTS access.
* guix/git.scm (show-progress): Reuse the result of the first call.
2023-02-19 01:00:06 +01:00
Ludovic Courtès 46f7011591
git: 'update-cached-checkout' returns the commit ID when given a tag.
Previously, starting with commit
efa578ecae, 'update-cached-checkout' would
return the OID of the annotated tag the tag points to.  With this change
it returns the OID of the commit object in all cases.

* guix/git.scm (resolve-reference): In the 'tag' case, call
'tag-target-id' and 'tag-lookup' when OID designates an annotated tag.
* tests/git.scm ("update-cached-checkout, tag"): New test.
2022-10-17 09:37:27 +02:00
Ludovic Courtès 26965563ef
git: 'update-cached-checkout' recognizes truncated commit IDs.
Fixes a regression introduced in
602527ab97 that broke
'tests/guix-build-branch.sh'.

* guix/git.scm (resolve-reference): Revert change from
602527ab97.
2022-10-15 00:44:09 +02:00
Ludovic Courtès 602527ab97
git: Factorize 'commit-id?' predicate.
* guix/git.scm (commit-id?): New procedure, copied from (guix swh).
(resolve-reference): Use it instead of inline code.
* guix/inferior.scm (channel-full-commit): Likewise.
2022-10-11 16:05:31 +02:00
Ludovic Courtès 87d49346f3
git: Add 'commit-descendant?'.
* guix/git.scm (commit-descendant?): New procedure.
* tests/git.scm ("commit-descendant?"): New test.
2022-02-14 11:23:07 +01:00
Sarah Morgensen 9f526f5dad
upstream: Support updating and fetching 'git-fetch' origins.
Updaters need to be modified to return 'git-reference' objects.
This patch modifies the 'generic-git' and 'minetest' updater,
but others might need to be modified as well.

* guix/git.scm (git-reference->git-checkout): New procedure.
* guix/upstream.scm (package-update/git-fetch): New procedure.
  (<upstream-source>)[urls]: Document it can be a 'git-reference'.
  (%method-updates): Add 'git-fetch' mapping.
  (update-package-source): Support 'git-reference' sources.
  (upstream-source-compiler/url-fetch): Split off from ...
  (upstream-source-compiler): ... this, and call ...
  (upstream-source-compiler/git-fetch): ... this new procedure if the URL
  field contains a 'git-reference'.
* guix/import/git.scm
  (latest-git-tag-version): Always return two values and document that the tag
  is returned as well.
  (latest-git-release)[urls]: Use the 'git-reference' instead of the
  repository URL.
* guix/import/minetest.scm (latest-minetest-release)[urls]: Don't wrap the
  'git-reference' in a list.
* tests/minetest.scm (upstream-source->sexp): Adjust to new convention.

Co-authored-by: Maxime Devos <maximedevos@telenet.be>
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2022-01-06 16:27:30 +01:00
Ludovic Courtès dce2cf311b
git: 'reference-available?' recognizes 'tag-or-commit'.
* guix/git.scm (reference-available?): Handle 'tag-or-commit' with a
40-digit hex string.
2021-09-18 23:08:32 +02:00
Ludovic Courtès 05f44c2d85
git: 'update-cached-checkout' can fall back to SWH when cloning.
Fixes <https://issues.guix.gnu.org/44187>.
Reported by zimoun <zimon.toutoune@gmail.com>.

* guix/git.scm (GITERR_HTTP): New variable.
(clone-from-swh, clone/swh-fallback): New procedures.
(update-cached-checkout): Use 'clone/swh-fallback' instead of 'clone*'.
2021-09-18 23:08:32 +02:00
Xinglu Chen 59ee10754e
import: Add 'generic-git' updater.
* guix/git.scm (ls-remote-refs): New procedure.
* tests/git.scm ("remote-refs" "remote-refs: only tags"): New tests.
* guix/import/git.scm: New file.
* doc/guix.texi (Invoking guix refresh): Document it.
* tests/import-git.scm: New test file.
* Makefile.am (MODULES, SCM_TESTS): Register the new files.

Co-authored-by: Sarah Morgensen <iskarian@mgsn.dev>
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2021-09-18 19:37:45 +02:00
Marius Bakke 16ef7b4938
transformations: Git tags and 'git describe' style IDs are used as version.
* guix/transformations.scm (commit->version-string): New procedure.  Use git
tags and 'git describe' style identifiers directly.
(transform-package-source-commit): Adjust accordingly.
* tests/transformations.scm
("options->transformation, with-commit, version transformation"): New test.
* doc/guix.texi (Package Transformation Options): Mention the 'git describe'
style.
2021-09-08 18:03:50 +02:00
Marius Bakke 1dc3825e99
git: 'resolve-reference' handles 'git describe'-style commit IDs.
* guix/git.scm (resolve-reference): Rewrite tag-or-commit case to recognize
'git describe' style identifiers and resolve them as commits.
* doc/guix.texi (origin Reference): Mention it.
2021-09-08 18:03:50 +02:00
Ludovic Courtès baf0a42882
git: Update the mtime of the just-updated checkout.
Reported by zimoun <zimon.toutoune@gmail.com>.

Previously, the mtime of CACHE-DIRECTORY may or may not have been
updated after a pull.  Thus, 'maybe-remove-expired-cache-entries' could
potentially delete CACHE-DIRECTORY right before it's returned.

* guix/git.scm (update-cached-checkout): Call 'utime' on CACHE-DIRECTORY.
2021-06-12 00:49:32 +02:00
Ludovic Courtès fab8ab7617
git: Honor proxy settings when fetching submodules.
Fixes <https://bugs.gnu.org/44593>.

* guix/git.scm (update-submodules): Add #:fetch-options and honor it.
(update-cached-checkout): Pass #:fetch-options to 'update-submodules'.
* doc/guix.texi (Requirements): Adjust comment about Guile-Git.
2021-04-14 22:51:38 +02:00
Kyle Meyer cb41c15827
git: Update cached checkout to the remote HEAD by default.
Fixes <https://bugs.gnu.org/45187>.
Reported by Ricardo Wurmus <rekado@elephly.net>.

update-cached-checkout hard codes "master" as the default branch, leading to a
failure when the clone doesn't have a "master" branch.  Instead use the remote
HEAD symref as an indicator of what the primary branch is.

* guix/git.scm (resolve-reference): Support resolving symrefs.
(update-cached-checkout, latest-repository-commit): Change the default for REF
to the empty list and translate it to the remote HEAD symref.
(<git-checkout>): Change branch field's default to #f.
(git-checkout-compiler): When branch and commit fields are both #f, call
latest-repository-commit* with the empty list as the ref.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2021-04-10 22:59:52 +02:00
Ludovic Courtès 973b8af725
git: Remove unused variables.
This is a followup to 298f9d29d6, which
left those variables despite being unnecessary.

* guix/git.scm (clone*, update-cached-checkout): Remove unused
'auth-method' variable.
2021-04-02 23:22:14 +02:00
Ludovic Courtès 87b0001325
git: Periodically delete least-recently-used cached checkouts.
This ensures ~/.cache/guix/checkouts is periodically cleaned up.

* guix/git.scm (cached-checkout-expiration)
(%checkout-cache-cleanup-period): New variables.
(delete-checkout): New procedure.
(update-cached-checkout)[cache-entries]: New procedure.
Add call to 'maybe-remove-expired-cache-entries'.
* guix/cache.scm (file-expiration-time): Add optional 'timestamp'
parameter and honor it.
2021-01-13 16:26:58 +01:00
Ludovic Courtès cde3a69a37
git: 'reference-available?' handles short commit IDs.
Reported by Simon Tournier on #guix.

Until now 'reference-available?' would always return #f when passed a
short commit ID.

* guix/git.scm (reference-available?): Call 'object-lookup-prefix' when
COMMIT is shorter than 40 characters.
2020-12-04 23:45:09 +01:00
Ludovic Courtès 8425a9b60a
git: Support HTTP and HTTPS proxies.
This allows 'guix pull' and similar to fetch code over a proxy.

* guix/git.scm (make-default-fetch-options): Pass #:proxy-url.
2020-10-22 17:10:25 +02:00
Ludovic Courtès 298f9d29d6
git: Display a progress bar while fetching a repo.
Fixes <https://bugs.gnu.org/39260>.

This uses the API of the yet-to-be-released Guile-Git 0.4.0.  Using an
older version is still possible, but progress report is disabled.

* guix/git.scm (show-progress, make-default-fetch-options): New
procedures.
(clone*, update-cached-checkout): Use it instead of
'make-fetch-options'.
2020-10-22 17:10:25 +02:00
Ludovic Courtès 59bb1ae3a9
git: Require Guile-Git 0.3.0 or later.
* guix/git.scm (auth-supported?): Remove.
(clone*): Inline code that was dependent on AUTH-SUPPORTED?.
(update-cached-checkout): Likewise.
(resolve-reference): Remove check for 'object-lookup-prefix' and use it
unconditionally.
(load-git-submodules): Remove.
(update-submodules): Use 'repository-submodules', 'submodule-lookup',
etc. unconditionally.
(update-cached-checkout): Use 'repository-close!' unconditionally.
* m4/guix.m4 (GUIX_CHECK_GUILE_GIT): New macro.
* configure.ac: Use it and error out when it fails.
* doc/guix.texi (Requirements): Bump to Guile-Git 0.3.0.
2020-10-22 17:10:25 +02:00
Mathieu Othacehe 2fbbfe6ff1
git: Export url-cache-directory.
* guix/git.scm (url-cache-directory): Export it.
2020-09-06 15:40:54 +02:00
Ludovic Courtès a620c9d51d
git: 'update-cached-checkout' has a new #:check-out? parameter.
* guix/git.scm (update-cached-checkout): Add #:check-out? parameter and
honor it.
2020-07-23 00:22:25 +02:00
Ludovic Courtès 1c058c382a
git: Factorize 'resolve-reference'.
* guix/git.scm (resolve-reference): New procedure.
(switch-to-ref): Use it.
2020-07-23 00:22:25 +02:00
Ludovic Courtès 69db2993b5
git: Add 'with-git-error-handling'.
* guix/scripts/pull.scm (report-git-error, with-git-error-handling):
Move to...
* guix/git.scm: ... here.
* guix/scripts/time-machine.scm: Adjust accordingly.
2020-07-11 11:51:56 +02:00
Ludovic Courtès 72357e2170
git: 'commit-difference' really excludes the ancestors of #:excluded.
* guix/git.scm (commit-difference): Initialize VISITED to the closure of
OLD and EXCLUDED, as written in the docstring.
* tests/git.scm ("commit-difference, excluded commits"): Adjust
accordingly.
2020-06-09 00:34:52 +02:00
Ludovic Courtès e782756080
git-authenticate: Prevent removal of '.guix-authorizations'.
* guix/git-authenticate.scm (commit-authorized-keys)
[parents-have-authorizations-file?, assert-parents-lack-authorizations]:
New procedures.
Use the latter before returning DEFAULT-AUTHORIZATIONS.
* guix/git.scm (false-if-git-not-found): Export.
* guix/tests/git.scm (populate-git-repository): Add 'remove' clause.
* tests/git-authenticate.scm ("signed commits, .guix-authorizations removed"):
New test.
2020-06-07 23:10:46 +02:00
Ludovic Courtès 1fd7de45f2
git: 'update-cached-checkout' gracefully handles missing starting commit.
Fixes <https://bugs.gnu.org/41604>
Reported by John Soo <jsoo1@asu.edu> and zimoun <zimon.toutoune@gmail.com>.

* guix/git.scm (false-if-git-not-found): New macro.
(reference-available?): Use it.
(update-cached-checkout): Use it when looking up STARTING-COMMIT.
Set RELATION to 'unrelated when OLD is #false.
2020-06-07 23:10:46 +02:00
Ludovic Courtès 8d1d56578a
git: 'update-cached-checkout' returns the commit relation.
* guix/git.scm (update-cached-checkout): Add #:starting-commit
parameter.  Call 'commit-relation' when #:starting-commit is true.
Always return the relation or #f as the third value.
(latest-repository-commit): Adjust accordingly.
* guix/import/opam.scm (get-opam-repository): Likewise.
* tests/channels.scm ("latest-channel-instances includes channel dependencies")
("latest-channel-instances excludes duplicate channel dependencies"):
Update mock of 'update-cached-checkout' accordingly.
2020-05-25 00:00:28 +02:00
Ludovic Courtès c098c11be8
git: Add 'commit-relation'.
* guix/git.scm (commit-relation): New procedure.
* tests/git.scm ("commit-relation"): New test.
2020-05-25 00:00:28 +02:00
Ludovic Courtès 053b10c3ef
channels: Add mechanism to patch checkouts of the 'guix channel.
* guix/channels.scm (<patch>): New record type.
(apply-patches): New procedure.
(latest-channel-instance)[dot-git?]: New procedure.
Use 'update-cached-checkout' and 'add-to-store' instead of
'latest-repository-commit'.  Call 'apply-patches' when CHANNEL is the
'guix channel.
(%patches): New variable.
* guix/git.scm (url+commit->name): Make public.
* tests/channels.scm ("latest-channel-instances includes channel dependencies")
("latest-channel-instances excludes duplicate channel dependencies"):
Mock 'update-cached-checkout' instead of 'latest-repository-commit'.
Wrap body in 'with-store' and pass the store to 'latest-channel-instances'.
2020-05-07 10:06:15 +02:00
Ludovic Courtès efa578ecae
git: Don't try to resolve tags with 'tag-lookup'.
Fixes <https://bugs.gnu.org/40377>.
Reported by Brice Waegeneire <brice@waegenei.re>.

* guix/git.scm (switch-to-ref): In the 'tag case, remove call to
'tag-lookup'.
2020-04-02 23:15:11 +02:00
Ludovic Courtès a063bac618
git: Add missing exports for <git-checkout>.
* guix/git.scm (<git-checkout>): Export 'git-checkout-commit' and
'git-checkout-recursive?'.
2020-02-10 23:31:58 +01:00
Mathieu Othacehe e3e1a7ba08
git: Remove leftover pk call.
* guix/git.scm (update-cached-checkout): Remove leftover pk call.
2020-02-06 17:14:39 +01:00
Mathieu Othacehe c357474994
git: Add ssh authentication support.
If Guile-Git revision is >= 0.3.0, use SSH agent authentication method for
both clone and fetch calls.

* guix/git.scm (auth-supported?): New variable,
(clone*): set auth-method to ssh-agent if the variable above is true,
(update-cached-checkout): ditto.
2020-02-06 16:10:31 +01:00
Ludovic Courtès 058d0251bd
download, git: Refer to the right module in 'module-use!' call.
This fixes a regression introduced in
6a7c4636d4.

* guix/build/download.scm (load-gnutls): Call 'resolve-module' instead
of 'current-module'.
* guix/git.scm (load-git-submodules): Likewise.
2020-01-07 12:25:09 +01:00
Ludovic Courtès 6a7c4636d4
Adjust module autoloads.
In Guile < 2.9.7, autoloading a module would give you access to all its
bindings.  In future versions, autoloading a module gives access only to
the listed bindings, as per #:select (see <https://bugs.gnu.org/38895>).

This commit adjusts autoloads to the new semantics, allowing Guix to be
built with Guile 2.9.7/2.9.8.

* guix/build/download.scm <top level>: Remove call to 'module-autoload!'.
(load-gnutls): New procedure.
(tls-wrap): Call it.
* guix/git.scm <top level>: Remove call to 'module-autoload!'.
(load-git-submodules): New procedure.
(update-submodules): Call it instead of 'resolve-interface'.
* gnu/bootloader/grub.scm: Replace #:autoload with #:use-module.
* gnu/packages.scm: Likewise.
* gnu/packages/ssh.scm: Likewise.
* gnu/packages/tex.scm: Likewise.
* gnu/services/cuirass.scm: Likewise.
* gnu/services/mcron.scm: Likewise.
* guix/lint.scm: Augment list of bindings in #:autoload.
* guix/scripts/build.scm: Likewise.
* guix/scripts/gc.scm: Likewise.
* guix/scripts/pack.scm: Likewise.
* guix/scripts/publish.scm: Likewise.
* guix/scripts/pull.scm: Likewise.
* guix/utils.scm: Remove unnecessary #:autoload clauses; replace one
of them with #:use-module.
2020-01-06 16:31:54 +01:00
Ludovic Courtès 785af04a75
git: 'commit-difference' takes a list of excluded commits.
* guix/git.scm (commit-closure): Add 'visited' optional parameter.
(commit-difference): Add 'excluded' optional parameter; pass second
argument to 'commit-closure'.
* tests/git.scm ("commit-difference, excluded commits"): New test.
2019-12-27 13:52:49 +01:00
Ludovic Courtès 873f6f1334
git: Add 'commit-difference'.
* guix/git.scm (commit-closure, commit-difference): New procedures.
* guix/tests/git.scm, tests/git.scm: New files.
* Makefile.am (dist_noinst_DATA): Add guix/tests/git.scm.
(SCM_TESTS): Add tests/git.scm.
2019-09-23 10:38:43 +02:00
Ludovic Courtès a78dcb3d59
git: 'update-cached-checkout' avoids network access when unnecessary.
* guix/git.scm (reference-available?): New procedure.
(update-cached-checkout): Avoid call to 'remote-fetch' when REPOSITORY
already contains REF.
2019-09-23 10:38:43 +02:00
Ludovic Courtès 10a8c2bbc6
git: 'switch-to-ref' resolves tag targets.
* guix/git.scm (switch-to-ref): In the 'tag' case, resolve the target of
the tag.
* tests/guix-build-branch.sh: Adjust test accordingly.
2019-07-26 11:21:36 +02:00
Ludovic Courtès 177fecb57c
git: <git-checkout> allows tags in its 'commit' field.
Fixes <https://bugs.gnu.org/36371>.
Reported by Tobias Geerinckx-Rice <me@tobias.gr>.

* guix/git.scm (git-checkout-compiler): Pass 'tag-or-commit' to
'latest-repository-commit*'.
* doc/guix.texi (Package Transformation Options): Update '--with-commit'
documentation accordingly.
* tests/guix-build-branch.sh: Add test.
2019-07-26 11:21:36 +02:00
Ludovic Courtès c4c2449fea
git: 'update-cached-checkout' supports a 'tag-or-commit' type of ref.
* guix/git.scm (switch-to-ref)[obj]: Wrap in 'resolve' lambda.  Add
'tag-or-commit' case.
(update-cached-checkout): Document it.
2019-07-26 11:21:36 +02:00
Ludovic Courtès 1d8b10d00f
git: Add an exception printer for 'git-error'.
* guix/git.scm (print-git-error): New procedure.
<top level>: Call 'set-exception-printer!'.
2019-02-11 23:23:28 +01:00
Ludovic Courtès bc041b3e26
git: Always use the system certificates by default.
'guix pull' was always doing it, and now '--with-branch' & co. will do
it as well.

* guix/git.scm (honor-system-x509-certificates!): New procedure.
(%certificates-initialized?): New variable.
(with-libgit2): Add call to 'honor-system-x509-certificates!'.
* guix/scripts/pull.scm (honor-x509-certificates): Call
'honor-system-x509-certificates!' and fall back to
'honor-lets-encrypt-certificates!'.
2019-02-08 10:41:13 +01:00
Ludovic Courtès 06fff484ce
git: Add a 'recursive?' field to <git-checkout> records.
* guix/git.scm (<git-checkout>)[recursive?]: New field.
(latest-repository-commit*): Add #:recursive? and honor it.
(git-checkout-compiler): Honor the 'recursive?' field of CHECKOUT.
2019-02-08 10:41:13 +01:00
Ludovic Courtès 60cbc6a8df
git: Support recursive updates of submodules.
* guix/git.scm: Autoload (git submodule).
(url-cache-directory): Add #:recursive? and honor it.
(call-with-repository): New procedure.
(with-repository): New macro.
(update-submodules): New procedure.
(update-cached-checkout): Add #:recursive? and #:log-port and honor
them.
(latest-repository-commit): Add #:recursive? and honor it.
[dot-git?]: Recognize ".git" regular files when RECURSIVE? is true.
2019-02-08 10:41:13 +01:00
Ludovic Courtès a3d77c51bc
git: Nicely report '--with-commit' errors.
* guix/git.scm (latest-repository-commit*): Rewrite to catch
'git-error'.
* po/guix/POTFILES.in: Add guix/git.scm.
* tests/guix-build-branch.sh: Test --with-commit errors.
2018-11-30 17:03:04 +01:00
Ludovic Courtès b18f7234aa
guix build: Add '--with-commit'.
* guix/git.scm (<git-checkout>)[commit]: New field.
(git-checkout-compiler): Honor it.
* guix/scripts/build.scm (evaluate-git-replacement-specs): Add 'proc'
parameter and honor it.
(transform-package-source-branch)[replace]: New procedure.
Adjust 'evaluate-git-replacement-specs' accordingly.
(transform-package-source-commit): New procedure.
(%transformations, %transformation-options)
(show-transformation-options-help): Add 'with-commit'.
* tests/guix-build-branch.sh: Add test.
* doc/guix.texi (Package Transformation Options): Document it.
2018-11-30 17:03:04 +01:00
Ludovic Courtès 49ae3f6d89
git: Add <git-checkout> record type.
* guix/git.scm (<git-checkout>): New record type.
(latest-repository-commit*): New procedure.
(git-checkout-compiler): New gexp compiler.
2018-11-30 17:03:04 +01:00