launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #23180
[Merge] lp:~cjwatson/launchpad/fix-github-blob-dot-git into lp:launchpad
Colin Watson has proposed merging lp:~cjwatson/launchpad/fix-github-blob-dot-git into lp:launchpad.
Commit message:
Fix handling of trailing ".git" when fetching blobs from GitHub.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/fix-github-blob-dot-git/+merge/361087
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/fix-github-blob-dot-git into lp:launchpad.
=== modified file 'lib/lp/code/model/gitref.py'
--- lib/lp/code/model/gitref.py 2018-11-09 22:06:43 +0000
+++ lib/lp/code/model/gitref.py 2018-12-18 18:00:51 +0000
@@ -686,7 +686,7 @@
def _fetch_blob_from_github(repository_url, ref_path, filename):
repo_path = urlsplit(repository_url).path.strip("/")
if repo_path.endswith(".git"):
- repo_path = repo_path[:len(".git")]
+ repo_path = repo_path[:-len(".git")]
try:
response = urlfetch(
"https://raw.githubusercontent.com/%s/%s/%s" % (
=== modified file 'lib/lp/code/model/tests/test_gitref.py'
--- lib/lp/code/model/tests/test_gitref.py 2018-11-09 22:06:43 +0000
+++ lib/lp/code/model/tests/test_gitref.py 2018-12-18 18:00:51 +0000
@@ -421,6 +421,16 @@
self.assertEqual(b"foo", ref.getBlob("dir/file"))
@responses.activate
+ def test_remote_github_trailing_dot_git(self):
+ ref = self.factory.makeGitRefRemote(
+ repository_url="https://github.com/owner/name.git", path="HEAD")
+ responses.add(
+ "GET",
+ "https://raw.githubusercontent.com/owner/name/HEAD/dir/file",
+ body=b"foo")
+ self.assertEqual(b"foo", ref.getBlob("dir/file"))
+
+ @responses.activate
def test_remote_github_404(self):
ref = self.factory.makeGitRefRemote(
repository_url="https://github.com/owner/name", path="HEAD")
Follow ups