From 3593f5e3a070747188a37319fb90872844ef4839 Mon Sep 17 00:00:00 2001 From: David Russell Date: Fri, 25 Aug 2017 17:08:55 +0700 Subject: [PATCH] Added support for compounded [pre/post] branch names. --- app/com/gitpitch/git/GRS.java | 15 ++++++++++++++- app/com/gitpitch/git/vendors/BitBucket.java | 2 +- app/com/gitpitch/git/vendors/GitBucket.java | 2 +- app/com/gitpitch/git/vendors/GitHub.java | 2 +- app/com/gitpitch/git/vendors/GitLab.java | 2 +- app/com/gitpitch/git/vendors/Gitea.java | 2 +- app/com/gitpitch/git/vendors/Gogs.java | 2 +- 7 files changed, 20 insertions(+), 7 deletions(-) diff --git a/app/com/gitpitch/git/GRS.java b/app/com/gitpitch/git/GRS.java index ec271e2..e2d0dbf 100644 --- a/app/com/gitpitch/git/GRS.java +++ b/app/com/gitpitch/git/GRS.java @@ -39,6 +39,7 @@ public class GRS { private final String apiToken; private final String apiTokenHeader; private final String rawBase; + private final String branchDelim; private final boolean isDefault; private GRS(String name, @@ -48,6 +49,7 @@ public class GRS { String apiToken, String apiTokenHeader, String rawBase, + String branchDelim, boolean isDefault) { this.name = name; @@ -57,6 +59,7 @@ public class GRS { this.apiToken = apiToken; this.apiTokenHeader = apiTokenHeader; this.rawBase = rawBase; + this.branchDelim = branchDelim; this.isDefault = isDefault; } @@ -69,12 +72,13 @@ public class GRS { String apiToken = grsCfg.get("apitoken"); String apiTokenHeader = grsCfg.get("apitokenheader"); String rawBase = grsCfg.get("rawbase"); + String branchDelim = grsCfg.get("branchdelim"); boolean isDefault = Boolean.parseBoolean(grsCfg.get("default")); if(name != null && type != null && site != null && apiBase != null && rawBase != null) { return new GRS(name, type, site, apiBase, apiToken, - apiTokenHeader, rawBase, isDefault); + apiTokenHeader, rawBase, branchDelim, isDefault); } else { return null; } @@ -87,6 +91,13 @@ public class GRS { public String getApiToken() { return apiToken; } public String getApiTokenHeader() { return apiTokenHeader; } public String getRawBase() { return rawBase; } + public String compoundBranch(String branch) { + if(branch != null && branchDelim != null) { + return branch.replaceAll(branchDelim, COMPOUNDED_BRANCH); + } else { + return branch; + } + } public boolean isDefault() { return isDefault; } public Map getHeaders() { @@ -101,4 +112,6 @@ public class GRS { return "GRS[ " + name + " ][ " + type + " ]"; } + private static final String COMPOUNDED_BRANCH = "/"; + } diff --git a/app/com/gitpitch/git/vendors/BitBucket.java b/app/com/gitpitch/git/vendors/BitBucket.java index ee392cf..8d8fb8c 100644 --- a/app/com/gitpitch/git/vendors/BitBucket.java +++ b/app/com/gitpitch/git/vendors/BitBucket.java @@ -55,7 +55,7 @@ public class BitBucket extends GRSService { .append(SLASH) .append(pp.repo) .append(BITBUCKET_RAW) - .append(pp.branch) + .append(grs.compoundBranch(pp.branch)) .append(SLASH) .toString(); } diff --git a/app/com/gitpitch/git/vendors/GitBucket.java b/app/com/gitpitch/git/vendors/GitBucket.java index 2281e8e..22ae8c7 100644 --- a/app/com/gitpitch/git/vendors/GitBucket.java +++ b/app/com/gitpitch/git/vendors/GitBucket.java @@ -49,7 +49,7 @@ public class GitBucket extends GitHub { .append(pp.repo) .append(SLASH) .append(GITBUCKET_RAW_API) - .append(pp.branch) + .append(grs.compoundBranch(pp.branch)) .append(SLASH) .toString(); } diff --git a/app/com/gitpitch/git/vendors/GitHub.java b/app/com/gitpitch/git/vendors/GitHub.java index 3cbf54f..1d9c36a 100644 --- a/app/com/gitpitch/git/vendors/GitHub.java +++ b/app/com/gitpitch/git/vendors/GitHub.java @@ -55,7 +55,7 @@ public class GitHub extends GRSService { .append(SLASH) .append(pp.repo) .append(SLASH) - .append(pp.branch) + .append(grs.compoundBranch(pp.branch)) .append(SLASH) .toString(); } diff --git a/app/com/gitpitch/git/vendors/GitLab.java b/app/com/gitpitch/git/vendors/GitLab.java index 0bc4d32..556c721 100644 --- a/app/com/gitpitch/git/vendors/GitLab.java +++ b/app/com/gitpitch/git/vendors/GitLab.java @@ -55,7 +55,7 @@ public class GitLab extends GRSService { .append(SLASH) .append(pp.repo) .append(GITLAB_RAW) - .append(pp.branch) + .append(grs.compoundBranch(pp.branch)) .append(SLASH) .toString(); } diff --git a/app/com/gitpitch/git/vendors/Gitea.java b/app/com/gitpitch/git/vendors/Gitea.java index 1bc8110..cce3fa8 100644 --- a/app/com/gitpitch/git/vendors/Gitea.java +++ b/app/com/gitpitch/git/vendors/Gitea.java @@ -55,7 +55,7 @@ public class Gitea extends GRSService { .append(SLASH) .append(pp.repo) .append(GITEA_RAW) - .append(pp.branch) + .append(grs.compoundBranch(pp.branch)) .append(SLASH) .toString(); } diff --git a/app/com/gitpitch/git/vendors/Gogs.java b/app/com/gitpitch/git/vendors/Gogs.java index 8ac85bd..3eed2c5 100644 --- a/app/com/gitpitch/git/vendors/Gogs.java +++ b/app/com/gitpitch/git/vendors/Gogs.java @@ -55,7 +55,7 @@ public class Gogs extends GRSService { .append(SLASH) .append(pp.repo) .append(GOGS_RAW) - .append(pp.branch) + .append(grs.compoundBranch(pp.branch)) .append(SLASH) .toString(); }