Kris De Volder
2019-01-31 12:49:44 -08:00
parent 44832b3787
commit 78f6380e21
2 changed files with 31 additions and 2 deletions

View File

@@ -89,10 +89,14 @@ public class GithubValueParsers {
for (String expectedPrefix : GithubRepoContentAssistant.URI_PREFIXES) {
int lastChar = expectedPrefix.length()-1;
if (str.startsWith(expectedPrefix.substring(0, lastChar))) {
if (str.charAt(lastChar)==expectedPrefix.charAt(lastChar)) {
char actualSeparator = str.charAt(lastChar);
char expectedSeparator = expectedPrefix.charAt(lastChar);
if (actualSeparator==expectedSeparator) {
return expectedPrefix;
}
throw new ValueParseException("Expecting a '"+expectedPrefix.charAt(lastChar)+"'", lastChar, lastChar+1);
if (actualSeparator==':' || actualSeparator == '/') {
throw new ValueParseException("Expecting a '"+expectedSeparator+"'", lastChar, lastChar+1);
}
}
}
return null;

View File

@@ -4752,6 +4752,31 @@ public class ConcourseEditorTest {
);
}
@Test public void githubUriReconciling_bug_194() throws Exception {
//See: https://github.com/spring-projects/sts4/issues/194
Editor editor;
editor = harness.newEditor(
"resources:\n" +
"- name: my-repo\n" +
" type: git\n" +
" source:\n" +
" uri: git@github.computer.com:me/repo.git\n"
);
editor.assertProblems("my-repo|Unused");
editor = harness.newEditor(
"resources:\n" +
"- name: my-repo\n" +
" type: git\n" +
" source:\n" +
" uri: https://github.computer.com/me/repo.git\n"
);
editor.assertProblems("my-repo|Unused");
}
@Test public void githubUriReconciling() throws Exception {
when(github.getReposForOwner("the-owner")).thenReturn(ImmutableList.of(
"nice-repo", "cool-project", "good-stuff"