diff --git a/810-ng-triggers/src/main/java/io/harness/ngtriggers/service/impl/NGTriggerServiceImpl.java b/810-ng-triggers/src/main/java/io/harness/ngtriggers/service/impl/NGTriggerServiceImpl.java index 81a7c2b83c674..1b812616ce525 100644 --- a/810-ng-triggers/src/main/java/io/harness/ngtriggers/service/impl/NGTriggerServiceImpl.java +++ b/810-ng-triggers/src/main/java/io/harness/ngtriggers/service/impl/NGTriggerServiceImpl.java @@ -134,7 +134,7 @@ public class NGTriggerServiceImpl implements NGTriggerService { private static final String TRIGGER = "trigger"; private static final String INPUT_YAML = "inputYaml"; - private static final String DUP_KEY_EXP_FORMAT_STRING = "Trigger [%s] already exists"; + private static final String DUP_KEY_EXP_FORMAT_STRING = "Trigger [%s] already exists or is soft deleted"; @Override public NGTriggerEntity create(NGTriggerEntity ngTriggerEntity) { diff --git a/930-delegate-tasks/src/main/java/io/harness/delegate/exceptionhandler/handler/SCMExceptionHandler.java b/930-delegate-tasks/src/main/java/io/harness/delegate/exceptionhandler/handler/SCMExceptionHandler.java index d9106100a7fe6..e4d04c8fc21fc 100644 --- a/930-delegate-tasks/src/main/java/io/harness/delegate/exceptionhandler/handler/SCMExceptionHandler.java +++ b/930-delegate-tasks/src/main/java/io/harness/delegate/exceptionhandler/handler/SCMExceptionHandler.java @@ -35,9 +35,8 @@ public WingsException handleException(Exception exception) { ExplanationException.INVALID_GIT_API_AUTHORIZATION, new InvalidRequestException(exception.getMessage(), USER)); } else if (errorCode == ErrorCode.INVALID_REQUEST) { - return NestedExceptionUtils.hintWithExplanationException(HintException.HINT_SCM_INVALID_REQUEST, - ExplanationException.EXPLANATION_SCM_INVALID_REQUEST, - new InvalidRequestException("SCM service running with delegate has error", USER)); + return NestedExceptionUtils.hintWithExplanationException("Something went wrong with SCM", + "SCM is not running with delegate agent", new InvalidRequestException(exception.getMessage(), USER)); } return new InvalidRequestException(exception.getMessage(), USER); } diff --git a/960-api-services/src/main/java/io/harness/git/GitClientHelper.java b/960-api-services/src/main/java/io/harness/git/GitClientHelper.java index 6f0fa6737a7f3..dfc5cac207577 100644 --- a/960-api-services/src/main/java/io/harness/git/GitClientHelper.java +++ b/960-api-services/src/main/java/io/harness/git/GitClientHelper.java @@ -135,14 +135,18 @@ public static String getGitOwner(String url, boolean isAccountLevelConnector) { } public static boolean isGithubSAAS(String url) { - return getGitSCM(url).equals("github.com"); + String host = getGitSCM(url); + return host.equals("github.com") || host.equals("www.github.com"); } + public static boolean isGitlabSAAS(String url) { - return getGitSCM(url).contains("gitlab.com"); + String host = getGitSCM(url); + return host.equals("gitlab.com") || host.equals("www.gitlab.com"); } public static boolean isBitBucketSAAS(String url) { - return getGitSCM(url).contains("bitbucket.org"); + String host = getGitSCM(url); + return host.equals("bitbucket.org") || host.equals("www.bitbucket.org"); } public static String getGithubApiURL(String url) { diff --git a/960-api-services/src/test/java/io/harness/git/GitClientHelperTest.java b/960-api-services/src/test/java/io/harness/git/GitClientHelperTest.java index d8c4d6d8e3c86..a037474acab96 100644 --- a/960-api-services/src/test/java/io/harness/git/GitClientHelperTest.java +++ b/960-api-services/src/test/java/io/harness/git/GitClientHelperTest.java @@ -20,6 +20,7 @@ import static io.harness.rule.OwnerRule.ABOSII; import static io.harness.rule.OwnerRule.ARVIND; import static io.harness.rule.OwnerRule.DEEPAK; +import static io.harness.rule.OwnerRule.DEV_MITTAL; import static io.harness.rule.OwnerRule.HARSH; import static io.harness.rule.OwnerRule.JAMIE; import static io.harness.rule.OwnerRule.JELENA; @@ -433,4 +434,65 @@ public void testGetChangeType() throws Exception { assertThat(gitClientHelper.getChangeType(RENAME)).isEqualTo(ChangeType.RENAME); assertThat(gitClientHelper.getChangeType(COPY)).isEqualTo(null); } + + @Test + @Owner(developers = DEV_MITTAL) + @Category(UnitTests.class) + public void testGetGithubApiURL() { + assertThat(GitClientHelper.getGithubApiURL("https://github.com/devkimittal/harness-core.git")) + .isEqualTo("https://api.github.com/"); + assertThat(GitClientHelper.getGithubApiURL("https://www.github.com/devkimittal/harness-core.git")) + .isEqualTo("https://api.github.com/"); + assertThat(GitClientHelper.getGithubApiURL("https://www.github.com/devkimittal/harness-core")) + .isEqualTo("https://api.github.com/"); + assertThat(GitClientHelper.getGithubApiURL("https://paypal.github.com/devkimittal/harness-core.git")) + .isEqualTo("https://paypal.github.com/api/v3/"); + assertThat(GitClientHelper.getGithubApiURL("https://github.paypal.com/devkimittal/harness-core.git")) + .isEqualTo("https://github.paypal.com/api/v3/"); + assertThat(GitClientHelper.getGithubApiURL("git@github.com:harness/harness-core.git")) + .isEqualTo("https://api.github.com/"); + assertThat(GitClientHelper.getGithubApiURL("git@www.github.com:harness/harness-core.git")) + .isEqualTo("https://api.github.com/"); + } + + @Test + @Owner(developers = DEV_MITTAL) + @Category(UnitTests.class) + public void testGetGitlabApiURL() { + assertThat(GitClientHelper.getGitlabApiURL("https://gitlab.com/devki.mittal/test.git")) + .isEqualTo("https://gitlab.com/"); + assertThat(GitClientHelper.getGitlabApiURL("https://www.gitlab.com/devki.mittal/test.git")) + .isEqualTo("https://gitlab.com/"); + assertThat(GitClientHelper.getGitlabApiURL("https://gitlab.com/devki.mittal/test")) + .isEqualTo("https://gitlab.com/"); + assertThat(GitClientHelper.getGitlabApiURL("https://paypal.gitlab.com/devki.mittal/test.git")) + .isEqualTo("https://paypal.gitlab.com/"); + assertThat(GitClientHelper.getGitlabApiURL("https://gitlab.paypal.com/devki.mittal/test.git")) + .isEqualTo("https://gitlab.paypal.com/"); + assertThat(GitClientHelper.getGitlabApiURL("git@gitlab.com:devki.mittal/test.git")) + .isEqualTo("https://gitlab.com/"); + assertThat(GitClientHelper.getGitlabApiURL("git@www.gitlab.com:devki.mittal/test.git")) + .isEqualTo("https://gitlab.com/"); + } + + @Test + @Owner(developers = DEV_MITTAL) + @Category(UnitTests.class) + public void testGetBitBucketApiURL() { + assertThat(GitClientHelper.getBitBucketApiURL("https://devmittalciv16@bitbucket.org/devmittalciv16/ci_3446.git")) + .isEqualTo("https://api.bitbucket.org/"); + assertThat( + GitClientHelper.getBitBucketApiURL("https://www.devmittalciv16@bitbucket.org/devmittalciv16/ci_3446.git")) + .isEqualTo("https://api.bitbucket.org/"); + assertThat(GitClientHelper.getBitBucketApiURL("https://devmittalciv16@bitbucket.org/devmittalciv16/ci_3446")) + .isEqualTo("https://api.bitbucket.org/"); + assertThat(GitClientHelper.getBitBucketApiURL("https://devmittalciv16@bitbucket.paypal.org/devmittalciv16/ci_3446")) + .isEqualTo("https://bitbucket.paypal.org/"); + assertThat(GitClientHelper.getBitBucketApiURL("https://devmittalciv16@paypal.bitbucket.org/devmittalciv16/ci_3446")) + .isEqualTo("https://paypal.bitbucket.org/"); + assertThat(GitClientHelper.getBitBucketApiURL("git@bitbucket.org:devmittalciv16/ci_3446.git")) + .isEqualTo("https://api.bitbucket.org/"); + assertThat(GitClientHelper.getBitBucketApiURL("git@www.bitbucket.org:devmittalciv16/ci_3446.git")) + .isEqualTo("https://api.bitbucket.org/"); + } } diff --git a/README.md b/README.md index bdfb6e30f1cef..6b4e664ee5f79 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,18 @@ -This repo contains code used in the [Harness CD Community Edition](https://github.com/harness/harness-cd-community) which is licensed under the [PolyForm Shield License 1.0.0](./licenses/PolyForm-Shield-1.0.0.txt). This repo also contains code belonging to Harness CD Enterprise Plan which is licensed under the [PolyForm Free Trial License 1.0.0](./licenses/PolyForm-Free-Trial-1.0.0.txt). You may obtain a copy of these licenses in the [licenses](./licenses/) directory at the root of this repository. - -harness-core Project Dev environment setup instructions -================================================== -## On MacOS - +This repo contains code used in the [Harness CD Community Edition](https://github.com/harness/harness-cd-community) which is licensed under the [PolyForm Shield License 1.0.0](./licenses/PolyForm-Shield-1.0.0.txt). This repo also contains code belonging to Harness CD Enterprise Plan which is licensed under the [PolyForm Free Trial License 1.0.0](./licenses/PolyForm-Free-Trial-1.0.0.txt). You may obtain a copy of these licenses in the [licenses](./licenses/) directory at the root o ### Prerequisities 1. Install Homebrew: -``` +```vfvf /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ``` 2. Download and Install Java 8 - *Note: Brew will download and install the latest version of OpenJDK/JRE, its recommended to install OpenJDK/JRE_1.8.0_242 to be in sync with the version everyone is using in the team.* + *Note: Brew will downlosddffvad and install the latest version of OpenJDK/JRE, its recommended to install OpenJDK/JRE_1.8.0_242 to be in sync with the version everyone is using in the team.* To setup the recommended version, download the OpenJDK 1.8-242 (jdk8u242-b08) JRE .pkg from [AdoptOpenJDK](https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/tag/jdk8u242-b08) and install it. Make sure to update `JAVA_HOME` and `PATH` accordingly (see step 5). -3. Install bazel: +3. Install bazel:fvvdfv ``` brew install bazelisk @@ -27,7 +22,7 @@ brew install bazelisk ``` brew install npm ``` - +dfsv 5. Set up JAVA_HOME: create or add this to your bash profile `~/.bashrc` or `~/.zshrc` file and add following line: ``` export JAVA_HOME=$(/usr/libexec/java_home -v1.8) @@ -49,7 +44,7 @@ export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/H Complete this step only if you are actively working with the protocol buffer files. ``` brew tap bufbuild/buf -brew install buf +brew install bufsdcds ``` To check if your protobuf files are according to the coding standards execute in the root of the repo @@ -90,7 +85,7 @@ Official steps to install docker on mac: [docker.com](https://docs.docker.com/de NOTE: if you clone the repo to another location you will have to do this again. On the other side you will be getting fixes and updates with no extra effort. ### Build - +f jgfg g #### Some Bazel Best Practices you can follow before building harness-core locally. `https://harness.atlassian.net/wiki/spaces/BT/pages/1910047082/Bazel+best+practices+for+faster+and+efficient+builds.` @@ -252,7 +247,7 @@ echo "export PATH="$PATH:$HOME//bin" >> ~/.zshrc to format .graphql files: you can follow these steps: * `npm install --global prettier@1.19.1` - +csdvdf * `prettier --write --print-width=120 ` - formats given graphql file helper shell scripts: