Added support for compounded [pre/post] branch names.

This commit is contained in:
David Russell 2017-08-25 17:08:55 +07:00
parent 7a294929b0
commit 3593f5e3a0
7 changed files with 20 additions and 7 deletions

View File

@ -39,6 +39,7 @@ public class GRS {
private final String apiToken; private final String apiToken;
private final String apiTokenHeader; private final String apiTokenHeader;
private final String rawBase; private final String rawBase;
private final String branchDelim;
private final boolean isDefault; private final boolean isDefault;
private GRS(String name, private GRS(String name,
@ -48,6 +49,7 @@ public class GRS {
String apiToken, String apiToken,
String apiTokenHeader, String apiTokenHeader,
String rawBase, String rawBase,
String branchDelim,
boolean isDefault) { boolean isDefault) {
this.name = name; this.name = name;
@ -57,6 +59,7 @@ public class GRS {
this.apiToken = apiToken; this.apiToken = apiToken;
this.apiTokenHeader = apiTokenHeader; this.apiTokenHeader = apiTokenHeader;
this.rawBase = rawBase; this.rawBase = rawBase;
this.branchDelim = branchDelim;
this.isDefault = isDefault; this.isDefault = isDefault;
} }
@ -69,12 +72,13 @@ public class GRS {
String apiToken = grsCfg.get("apitoken"); String apiToken = grsCfg.get("apitoken");
String apiTokenHeader = grsCfg.get("apitokenheader"); String apiTokenHeader = grsCfg.get("apitokenheader");
String rawBase = grsCfg.get("rawbase"); String rawBase = grsCfg.get("rawbase");
String branchDelim = grsCfg.get("branchdelim");
boolean isDefault = Boolean.parseBoolean(grsCfg.get("default")); boolean isDefault = Boolean.parseBoolean(grsCfg.get("default"));
if(name != null && type != null && site != null && if(name != null && type != null && site != null &&
apiBase != null && rawBase != null) { apiBase != null && rawBase != null) {
return new GRS(name, type, site, apiBase, apiToken, return new GRS(name, type, site, apiBase, apiToken,
apiTokenHeader, rawBase, isDefault); apiTokenHeader, rawBase, branchDelim, isDefault);
} else { } else {
return null; return null;
} }
@ -87,6 +91,13 @@ public class GRS {
public String getApiToken() { return apiToken; } public String getApiToken() { return apiToken; }
public String getApiTokenHeader() { return apiTokenHeader; } public String getApiTokenHeader() { return apiTokenHeader; }
public String getRawBase() { return rawBase; } 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 boolean isDefault() { return isDefault; }
public Map<String,String> getHeaders() { public Map<String,String> getHeaders() {
@ -101,4 +112,6 @@ public class GRS {
return "GRS[ " + name + " ][ " + type + " ]"; return "GRS[ " + name + " ][ " + type + " ]";
} }
private static final String COMPOUNDED_BRANCH = "/";
} }

View File

@ -55,7 +55,7 @@ public class BitBucket extends GRSService {
.append(SLASH) .append(SLASH)
.append(pp.repo) .append(pp.repo)
.append(BITBUCKET_RAW) .append(BITBUCKET_RAW)
.append(pp.branch) .append(grs.compoundBranch(pp.branch))
.append(SLASH) .append(SLASH)
.toString(); .toString();
} }

View File

@ -49,7 +49,7 @@ public class GitBucket extends GitHub {
.append(pp.repo) .append(pp.repo)
.append(SLASH) .append(SLASH)
.append(GITBUCKET_RAW_API) .append(GITBUCKET_RAW_API)
.append(pp.branch) .append(grs.compoundBranch(pp.branch))
.append(SLASH) .append(SLASH)
.toString(); .toString();
} }

View File

@ -55,7 +55,7 @@ public class GitHub extends GRSService {
.append(SLASH) .append(SLASH)
.append(pp.repo) .append(pp.repo)
.append(SLASH) .append(SLASH)
.append(pp.branch) .append(grs.compoundBranch(pp.branch))
.append(SLASH) .append(SLASH)
.toString(); .toString();
} }

View File

@ -55,7 +55,7 @@ public class GitLab extends GRSService {
.append(SLASH) .append(SLASH)
.append(pp.repo) .append(pp.repo)
.append(GITLAB_RAW) .append(GITLAB_RAW)
.append(pp.branch) .append(grs.compoundBranch(pp.branch))
.append(SLASH) .append(SLASH)
.toString(); .toString();
} }

View File

@ -55,7 +55,7 @@ public class Gitea extends GRSService {
.append(SLASH) .append(SLASH)
.append(pp.repo) .append(pp.repo)
.append(GITEA_RAW) .append(GITEA_RAW)
.append(pp.branch) .append(grs.compoundBranch(pp.branch))
.append(SLASH) .append(SLASH)
.toString(); .toString();
} }

View File

@ -55,7 +55,7 @@ public class Gogs extends GRSService {
.append(SLASH) .append(SLASH)
.append(pp.repo) .append(pp.repo)
.append(GOGS_RAW) .append(GOGS_RAW)
.append(pp.branch) .append(grs.compoundBranch(pp.branch))
.append(SLASH) .append(SLASH)
.toString(); .toString();
} }