-
Notifications
You must be signed in to change notification settings - Fork 1
fix repo/path/tag detection to work with https repos #12
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
Open
serchaos
wants to merge
1
commit into
master
Choose a base branch
from
https-repo
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,3 +37,32 @@ func TestGenerateRepoNames(t *testing.T) { | |
| } | ||
| } | ||
| } | ||
|
|
||
| type detectPathTagCase struct { | ||
| repo string | ||
| expected string | ||
| } | ||
|
|
||
| var ( | ||
| testDetectPathTagCases = []detectPathTagCase{ | ||
| detectPathTagCase{ | ||
| repo: "git@github.com:foo/bar.git", | ||
| expected: "foo/bar", | ||
| }, | ||
| detectPathTagCase{ | ||
| repo: "https://github.com/foo/bar.git", | ||
| expected: "foo/bar", | ||
| }, | ||
| } | ||
| ) | ||
|
|
||
| func TestDetectRepoPathAndTag(t *testing.T) { | ||
| for _, testCase := range testDetectPathTagCases { | ||
| actual := extractRepo(testCase.repo) | ||
|
|
||
| if actual != testCase.expected { | ||
| t.Errorf("Expected (%q), got (%q)", testCase.expected, actual) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. super minor nit but since you're quoting the values with %q, there's not much need for the parens. I think the test error would be readable enough w/o them. |
||
| t.FailNow() | ||
| } | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I prefer tests where we include the "://" part as well. You'd have to add a condition for both "http" and "https" that way but it seems safer and a bit more clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: return an error when the repo starts w/ a prefix we don't expect to be able to handle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait after actually thinking about this, even the "git@..." repos are not guaranteed to have a particular prefix. So we should probably only look for "http://" and "https://" prefixes, then fall back. Maybe add some validation at the end to make sure whatever we end up with doesn't look like it has unexpected bits in it such as '/'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good on all counts, thanks for catching the prefix bit - I'll also pull in some more exhaustive test cases from whatever the remote spec allows. On some level we don't really care about prefix, we just want consistent fragment extraction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good.
On Tue, May 24, 2016 at 12:57 PM Kyle notifications@github.com wrote: