Learn more about these different git repos.
Other Git URLs
When creating a SPEC file from scratch with rpmautospec's %autorelease and %autochangelog, fedpkg --srpm fails with:
$ fedpkg --release f35 srpm Could not execute srpm: 'NoneType' object has no attribute 'head'
Similarly:
fedpkg --release f35 scratch-build --srpm --fail-fast sources file doesn't exist. Source files download skipped. Failed to get repository name from Git url or pushurl Could not execute scratch_build: 'NoneType' object has no attribute 'head'
This is caused by the fact that there is no GIT repo for rpmautospec to gather its history.
In pkg_history.py, there is a try except which allows self.repo to be None;
try: if hasattr(pygit2, "GIT_REPOSITORY_OPEN_NO_SEARCH"): kwargs = {"flags": pygit2.GIT_REPOSITORY_OPEN_NO_SEARCH} else: # pygit2 < 1.4.0 kwargs = {} # pygit2 < 1.2.0 can't cope with pathlib.Path objects self.repo = pygit2.Repository(str(self.path), **kwargs) except pygit2.GitError: self.repo = None
but it is assumed later that repo is not None:
if not head: head = self.repo[self.repo.head.target] diff_to_head = self.repo.diff(head) reflect_worktree = diff_to_head.stats.files_changed > 0 elif isinstance(head, str): head = self.repo[head]
If the repo is non existent, there should be a method to avoid the history logic, and either set the release to 1 or determine it only from the changelog file entries.
Metadata Update from @nphilipp: - Issue assigned to nphilipp
Fix queued here: https://pagure.io/fork/nphilipp/fedora-infra/rpmautospec/tree/main--random-fixes-and-additions
Metadata Update from @nphilipp: - Issue set to the milestone: So you call this production ready?
I may have been hit with this bug when trying to use rpmautospec after this commit https://github.com/Iolaum/fcust/tree/9a2ae8d25abc8e9864bee9759f46f370329f8f15 but it could be that I m doing something wrong with the spec file entries.
Commit b476f2b fixes this issue
Login to comment on this ticket.