You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR makes a big change to how the RemoteGitIndex performs fetches
(and clones) and subsequently reads blobs, to resolve issues discovered
while doing obi1kenobi/cargo-semver-checks#506
Previously when performing a fetch, we also updated references so that
HEAD pointed at the same commit as the remote HEAD. This works fine in
local operation and in tests, but had a drawback, namely
```
Error: Failed to update references to their new position to match their remote locations
Caused by:
0: The reflog could not be created or updated
1: reflog messages need a committer which isn't set
```
can occur in CI environments. My attempts to fix this...failed
(configuring a committer name + email before editing references).
Then I noticed frewsxcv/rust-crates-index#129
which....is just way better than that previous approach since we don't
need to edit references any longer just to be able to use
`repo.head_commit` for reading blobs, but rather just store the remote
HEAD when opening/fetching and retrieving the tree to lookup blobs from
that, sidestepping the whole issue with updating references.
There is a big difference between that PR though, in that this PR also
adds a function (`crate::utils::git::write_fetch_head`) to actually
write a FETCH_HEAD _similarly_ to how cargo, via git or libgit2 writes
FETCH_HEAD when performing a fetch on an index.
This was done for 2 reasons:
1. Performing a fetch of an index via this crate will now update the
index repository the same as cargo would, which makes this play nicer
with cargo and thus the wider ecosystem
2. I had already done (a slightly worse) version of writing a FETCH_HEAD
for
[cargo-deny](https://github.com/EmbarkStudios/cargo-deny/blob/main/src/advisories/helpers/db.rs#L451-L457),
because, AFAIK, retrieving the timestamp of the FETCH_HEAD file is by
far the [most/only
reliable](https://stackoverflow.com/questions/2993902/how-do-i-check-the-date-and-time-of-the-latest-git-pull-that-was-executed)
way to determine when a fetch was last performed on a repository. The
reason this was important for cargo deny is that it fetches advisory
databases, but can decide _not_ to fetch them if the user doesn't want
to perform network calls, however if they _never_ fetch from the remote
advisory db they run the risk of mistakenly thinking everything is fine
even if they have crate dependencies that have active advisories that
were added/modified since the last time they fetched. So until `gix`
adds support for writing FETCH_HEAD (which I think is planned, but
couldn't find it), making this function public allows cargo-deny or
others to also have a (simple, definitely not git/libgit2 compliant) way
to write a FETCH_HEAD with gix.
Copy file name to clipboardexpand all lines: CHANGELOG.md
+6
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9
9
10
10
<!-- next-header -->
11
11
## [Unreleased] - ReleaseDate
12
+
### Fixed
13
+
-[PR#7](https://github.com/EmbarkStudios/tame-index/pull/7) fixed an issue where `RemoteGitIndex::fetch` could fail in environments where the git committer was not configured.
14
+
15
+
### Changed
16
+
-[PR#7](https://github.com/EmbarkStudios/tame-index/pull/7) change how `RemoteGitIndex` looks up blobs. Previously fetching would actually update references, now however we write a `FETCH_HEAD` similarly to git/libgit2, and uses that (or other) reference to find the commit to use, rather than updating the HEAD to point to the same commit as the remote HEAD.
17
+
12
18
## [0.2.3] - 2023-07-26
13
19
### Fixed
14
20
-[PR#6](https://github.com/EmbarkStudios/tame-index/pull/6) fixed two bugs with git registries.
0 commit comments