Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

versiongetter: use a permissive AlternatesFS with git-go #3852

Merged
merged 2 commits into from
Oct 9, 2024

Conversation

database64128
Copy link
Contributor

@database64128 database64128 commented Oct 8, 2024

versiongetter does not work in Arch Linux's package build environment, because repo.Log(&git.LogOptions{From: head.Hash()}) somehow returns plumbing.ErrObjectNotFound.

It might take some time before I can find out the root cause and submit a fix, so here's the preliminary change that wraps errors with additional context.

Update: See the added comment in code.

Fixes #3409.

versiongetter does not work in Arch Linux's package build environment, because `repo.Log(&git.LogOptions{From: head.Hash()})` somehow returns `plumbing.ErrObjectNotFound`.

It might take some time before I can find out the root cause and submit a fix, so here's the preliminary change that wraps errors with additional context.
@aler9
Copy link
Member

aler9 commented Oct 8, 2024

Hello, the error message you've reported is usually triggered when repositories are pulled with --depth=1:

git clone --depth=1 https://github.com/bluenviron/mediamtx

When repositories are cloned in this way, the tag list is not available:

git tag

(this returns an empty list)

and the server is unable to get its tag.

In my opinion there are two ways to solve the issue:

  1. we can find an alternative way to get the server tag, that is compatible with --depth=1
  2. you have to alter the Arch Linux package in order to download the full repository.

I like the first approach better - try looking around.

@database64128
Copy link
Contributor Author

you have to alter the Arch Linux package in order to download the full repository.

AFAIK this is not possible. The makepkg program first clones the remote repository into a local mirror repository, and then clones the local mirror repository into a separate package src repository, and switches to a new makepkg branch, where the actual build script runs. There's no way to change how the src repository is set up.

Mirror repo config (mediamtx/config):

[core]
    repositoryformatversion = 0
    filemode = true
    bare = true
[remote "origin"]
    url = https://github.com/bluenviron/mediamtx.git
    fetch = +refs/*:refs/*
    mirror = true

src repo config (src/mediamtx/.git/config):

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "origin"]
    url = /home/database64128/repos/aur/mediamtx/mediamtx
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "main"]
    remote = origin
    merge = refs/heads/main

Inside the src repo, git log correctly shows the latest commit/tag:

commit 32d3fc55ccc631ad125462063b7bf387595209fe (HEAD -> makepkg, tag: v1.9.2)

@database64128
Copy link
Contributor Author

When repositories are cloned in this way, the tag list is not available:

The src repo is not cloned with --depth=1. The full tag list and commit history are available via git tag and git log.

repo.Tags() is actually able to iterate over all tags. repo.Log(&git.LogOptions{From: head.Hash()}) does not work and repo.Log(&git.LogOptions{All: true}) returns an iterator that immediately gives EOF.

@database64128
Copy link
Contributor Author

Likely the same issue as mentioned in go-git/go-git#1125 and go-git/go-git#1002. I'll update this PR once I get things working.

@database64128 database64128 changed the title versiongetter: wrap errors with additional context versiongetter: use a permissive AlternatesFS with git-go Oct 8, 2024
@database64128
Copy link
Contributor Author

Hi, I have pushed the fix to the branch and updated the PR title. It's now ready for review.

@aler9 aler9 merged commit 737ab9d into bluenviron:main Oct 9, 2024
6 checks passed
@aler9
Copy link
Member

aler9 commented Oct 9, 2024

I tested it on both Linux and Windows and it seems to be working. This has been merged.
Thanks for the patch and thanks for maintaining the Arch Linux package.

@database64128 database64128 deleted the versiongetter branch October 10, 2024 13:23
Copy link
Contributor

This issue is mentioned in release v1.9.3 🚀
Check out the entire changelog by clicking here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants