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

rpmautospec-plugin's git repo check is too strict #1290

Open
dennisklein opened this issue Jan 17, 2024 · 10 comments
Open

rpmautospec-plugin's git repo check is too strict #1290

dennisklein opened this issue Jan 17, 2024 · 10 comments
Labels
enhancement feature request, rfe

Comments

@dennisklein
Copy link

dennisklein commented Jan 17, 2024

distgit_git_dir = host_chroot_sources / ".git"
if not distgit_git_dir.is_dir():

This check fails for git submodules and multiple git worktrees (in such cases the .git file may not be a directory). Since rpmautospec already depends on pygit2 I propose to improve the git repo check with pygit2.discover_repository() which already supports submodules and worktrees.

Test with python -c "import pygit2; import os; print(pygit2.discover_repository(os.getcwd()))"

Possible implementation:

if not pygit2.discover_repository(host_chroot_sources):

If pygit2 as a new dependency is not desired, one could fall back to the return code of git rev-parse --git-dir.

@praiskup
Copy link
Member

@nphilipp fyi

@praiskup
Copy link
Member

@sgallagher fyi

@praiskup
Copy link
Member

@dennisklein thank you for reporting this!

@praiskup praiskup added the enhancement feature request, rfe label Jan 24, 2024
@nphilipp
Copy link
Contributor

@dennisklein good catch! In fact, we don’t want to have pygit2 as a dependency in this plugin – we changed it intentionally so that the bulk of the code is executed in the build root and outside has only minimal dependencies.

@nphilipp
Copy link
Contributor

@praiskup I lean towards implementing this check in rpmautospec_core and adapting the mock plugin to use it. What do you think?

@nphilipp
Copy link
Contributor

nphilipp commented Jan 25, 2024

@dennisklein Your check is too lenient, though 😉 (but the error message in the plugin is misleading): it works anywhere in the worktree, but it should only continue there if at the root. I guess I’ll just check for the presence of .git and if it’s a plain file, check that it begins with gitdir: .

@dennisklein
Copy link
Author

but it should only continue there if at the root

true, I didn't realize this aspect.

I guess I’ll just check for the presence of .git and if it’s a plain file, check that it begins with gitdir:

👍 Thank you!

@praiskup
Copy link
Member

@praiskup I lean towards implementing this check in rpmautospec_core and adapting the mock plugin to use it. What do you think?

Not sure if the mock plugin needs an update? But sounds good.

@nphilipp
Copy link
Contributor

nphilipp commented Feb 1, 2024

I’ve looked into it more closely and it seems like just checking these couple files or directories doesn’t cover all the options how a git work tree can be defined. So to me the question is if we can live with not supporting these corner cases – which we could by delegating this step to git itself but then it would have to become a dependency (and I’m not sure if it’s worthwhile).

@dennisklein
Copy link
Author

So to me the question is if we can live with not supporting these corner cases

To my current use case (submodules) it would be acceptable.

which we could by delegating this step to git itself

This sounds more future-proof as we would not be relying on implementation details of git.

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

No branches or pull requests

3 participants