From 20471b30da9a2d60a89576d73e3cbd2a43c02886 Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Thu, 1 Aug 2013 11:18:34 +0400 Subject: [PATCH] Github: show branches from source repository --- .../github/GithubCreatePullRequestAction.java | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubCreatePullRequestAction.java b/plugins/github/src/org/jetbrains/plugins/github/GithubCreatePullRequestAction.java index a85e27c1e5d2..0155eb17cddb 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/GithubCreatePullRequestAction.java +++ b/plugins/github/src/org/jetbrains/plugins/github/GithubCreatePullRequestAction.java @@ -275,6 +275,7 @@ public class GithubCreatePullRequestAction extends DumbAwareAction { final GithubAuthData auth = info.getAuthData(); final GithubRepoDetailed repo = info.getRepo(); final GithubRepo parent = repo.getParent(); + final GithubRepo source = repo.getSource(); result.addAll(getBranches(auth, repo.getUserName(), repo.getName())); @@ -282,9 +283,11 @@ public class GithubCreatePullRequestAction extends DumbAwareAction { result.addAll(getBranches(auth, parent.getUserName(), parent.getName())); } - if (upstreamPath != null && - !StringUtil.equalsIgnoreCase(upstreamPath.getUser(), repo.getUserName()) && - (parent == null || !StringUtil.equalsIgnoreCase(upstreamPath.getUser(), parent.getUserName()))) { + if (source != null && !equals(source, parent)) { + result.addAll(getBranches(auth, source.getUserName(), source.getName())); + } + + if (upstreamPath != null && !equals(upstreamPath, repo) && !equals(upstreamPath, parent) && !equals(upstreamPath, source)) { result.addAll(getBranches(auth, upstreamPath.getUser(), upstreamPath.getRepository())); } } @@ -314,6 +317,20 @@ public class GithubCreatePullRequestAction extends DumbAwareAction { } }); } + + private boolean equals(@NotNull GithubRepo repo1, @Nullable GithubRepo repo2) { + if (repo2 == null) { + return false; + } + return StringUtil.equalsIgnoreCase(repo1.getUserName(), repo2.getUserName()); + } + + private boolean equals(@NotNull GithubFullPath repo1, @Nullable GithubRepo repo2) { + if (repo2 == null) { + return false; + } + return StringUtil.equalsIgnoreCase(repo1.getUser(), repo2.getUserName()); + } }.execute(); }