scm.sr.ht: Overwrite fragment of source spec if needed v1 APPLIED

Conrad Hoffmann: 1
 Overwrite fragment of source spec if needed

 1 files changed, 4 insertions(+), 2 deletions(-)
#1220393 alpine.yml success
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/sr.ht-dev/patches/51838/mbox | git am -3
Learn more about email & git

[PATCH scm.sr.ht] Overwrite fragment of source spec if needed Export this patch

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):
scm.sr.ht/patches/alpine.yml: SUCCESS in 22s

[Overwrite fragment of source spec if needed][0] from [Conrad Hoffmann][1]

[0]: https://lists.sr.ht/~sircmpwn/sr.ht-dev/patches/51838
[1]: mailto:ch@bitfehler.net

✓ #1220393 SUCCESS scm.sr.ht/patches/alpine.yml https://builds.sr.ht/~sircmpwn/job/1220393

To git@git.sr.ht:~sircmpwn/scm.sr.ht
   e9a6399..37e5f61  master -> master