From 78f6380e21e5d83eab5ac061ebc100f85aac541c Mon Sep 17 00:00:00 2001 From: Kris De Volder Date: Thu, 31 Jan 2019 12:49:44 -0800 Subject: [PATCH] Fix for https://github.com/spring-projects/sts4/issues/194 --- .../concourse/github/GithubValueParsers.java | 8 ++++-- .../vscode/concourse/ConcourseEditorTest.java | 25 +++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/headless-services/concourse-language-server/src/main/java/org/springframework/ide/vscode/concourse/github/GithubValueParsers.java b/headless-services/concourse-language-server/src/main/java/org/springframework/ide/vscode/concourse/github/GithubValueParsers.java index 6f0c95837..7f357b634 100644 --- a/headless-services/concourse-language-server/src/main/java/org/springframework/ide/vscode/concourse/github/GithubValueParsers.java +++ b/headless-services/concourse-language-server/src/main/java/org/springframework/ide/vscode/concourse/github/GithubValueParsers.java @@ -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; diff --git a/headless-services/concourse-language-server/src/test/java/org/springframework/ide/vscode/concourse/ConcourseEditorTest.java b/headless-services/concourse-language-server/src/test/java/org/springframework/ide/vscode/concourse/ConcourseEditorTest.java index 3f7a1c252..ff3841e2c 100644 --- a/headless-services/concourse-language-server/src/test/java/org/springframework/ide/vscode/concourse/ConcourseEditorTest.java +++ b/headless-services/concourse-language-server/src/test/java/org/springframework/ide/vscode/concourse/ConcourseEditorTest.java @@ -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"