Skip to content

Commit

Permalink
support diff id as param - fix revision id parsing when null revision (
Browse files Browse the repository at this point in the history
  • Loading branch information
kageiit committed Mar 4, 2020
1 parent 80b996f commit c9818e6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Expand Up @@ -173,7 +173,8 @@ public Environment setUp(
Differential diff;
try {
diff = new Differential(diffClient.fetchDiff());
diff.setCommitMessage(diffClient.getCommitMessage(diff.getRevisionID(false)));
String revisionID = diff.getRevisionID(false);
diff.setCommitMessage(diffClient.getCommitMessage(revisionID));
diff.decorate(build, this.getPhabricatorURL(build.getParent()));

logger.info(CONDUIT_TAG, "Fetching differential from Conduit API");
Expand Down
Expand Up @@ -55,7 +55,8 @@ public String getDiffID() {
}

public String getRevisionID(boolean formatted) {
String rawRevisionId = (String) rawJSON.get("revisionID");
Object rawRevisionIdObj = rawJSON.get("revisionID");
String rawRevisionId = rawRevisionIdObj != null && !(rawRevisionIdObj instanceof net.sf.json.JSONNull) ? (String) rawRevisionIdObj : null;
if (rawRevisionId == null || rawRevisionId.equals("")) {
return null;
}
Expand Down
Expand Up @@ -148,6 +148,10 @@ public JSONObject postComment(String revisionID, String message) throws ConduitA
* @throws IOException
*/
public String getCommitMessage(String revisionID) throws ConduitAPIException, IOException {
// if no revision ID return null
if (revisionID == null) {
return "";
}
JSONObject params = new JSONObject().element("revision_id", revisionID);
JSONObject query = callConduit("differential.getcommitmessage", params);

Expand Down

0 comments on commit c9818e6

Please sign in to comment.