Currently, `_add_commit_id_fragment()` only tests if the `basename()` of
the sources spec matches the repo name. However, if a manifest contains
e.g. the source `https://git.sr.ht/~foo/repo#main`, the `basename()` is
"repo#main" and will not match the repo name "repo".
This causes problems, as automatically generated Manifests for patch
submissions may end with two source specs referencing the same repo,
causing the clone stage to fail.
A better approach was already taken in `_auto_setup_auto_source()` a few
lines above: properly parsing the URL and calling `basename()` only on
the path. Applying the same approach here fixes the issue.
---
scmsrht/submit.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/scmsrht/submit.py b/scmsrht/submit.py
index 01e1965..9617255 100644
--- a/scmsrht/submit.py
+++ b/scmsrht/submit.py
@@ -142,8 +142,10 @@ class BuildSubmitterBase:
def _add_commit_id_fragment(self, commit_id, m):
sources = m.get('sources', [])
for i, source in enumerate(sources):
- if os.path.basename(source) == self.repo.name:
- sources[i] = source + "#" + commit_id
+ srcurl = urlparse(source)
+ srcurl_repo_name = os.path.basename(srcurl.path)
+ if srcurl_repo_name == self.repo.name:
+ sources[i] = srcurl._replace(fragment=commit_id).geturl()
class SubmitResult:
def __init__(self):
--
2.45.0