Skip to content

Commit

Permalink
Merge pull request #219 from if6was9/cross-fork-compare
Browse files Browse the repository at this point in the history
#218 enable cross fork compare
  • Loading branch information
kohsuke committed Dec 1, 2015
2 parents 75a4081 + 512c921 commit 723bb89
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/main/java/org/kohsuke/github/GHRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,23 @@ public GHCompare getCompare(GHCommit id1, GHCommit id2) throws IOException {
}

public GHCompare getCompare(GHBranch id1, GHBranch id2) throws IOException {
return getCompare(id1.getName(),id2.getName());

GHRepository owner1 = id1.getOwner();
GHRepository owner2 = id2.getOwner();

// If the owner of the branches is different, we have a cross-fork compare.
if (owner1!=null && owner2!=null) {
String ownerName1 = owner1.getOwnerName();
String ownerName2 = owner2.getOwnerName();
if (!StringUtils.equals(ownerName1, ownerName2)) {
String qualifiedName1 = String.format("%s:%s", ownerName1, id1.getName());
String qualifiedName2 = String.format("%s:%s", ownerName2, id2.getName());
return getCompare(qualifiedName1, qualifiedName2);
}
}

return getCompare(id1.getName(), id2.getName());

}

/**
Expand Down

0 comments on commit 723bb89

Please sign in to comment.