diff options
author | Kevin Sawicki | 2011-09-07 21:55:59 +0000 |
---|---|---|
committer | Kevin Sawicki | 2011-09-07 21:55:59 +0000 |
commit | 9646add7f84af430f14e0db4d687e2da93ddf4cf (patch) | |
tree | b364e57e23e8df4543673fbaed0ec6bb0c4fec4a /org.eclipse.mylyn.github.core/src/org/eclipse | |
parent | a67f83050e0a2b9d7712a7899f126f783824c915 (diff) | |
download | egit-github-9646add7f84af430f14e0db4d687e2da93ddf4cf.tar.gz egit-github-9646add7f84af430f14e0db4d687e2da93ddf4cf.tar.xz egit-github-9646add7f84af430f14e0db4d687e2da93ddf4cf.zip |
Use origin remote if pull request is intra-repository
Change-Id: I1fc1185c2d41bef2d958d61bf89f04a939d01d14
Signed-off-by: Kevin Sawicki <kevin@github.com>
Diffstat (limited to 'org.eclipse.mylyn.github.core/src/org/eclipse')
-rw-r--r-- | org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/pr/PullRequestUtils.java | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/pr/PullRequestUtils.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/pr/PullRequestUtils.java index b16620bb..bf24f67f 100644 --- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/pr/PullRequestUtils.java +++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/pr/PullRequestUtils.java @@ -18,6 +18,7 @@ import org.eclipse.egit.core.Activator; import org.eclipse.egit.core.RepositoryCache; import org.eclipse.egit.github.core.PullRequest; import org.eclipse.egit.github.core.PullRequestMarker; +import org.eclipse.egit.github.core.User; import org.eclipse.egit.github.core.util.UrlUtils; import org.eclipse.jgit.lib.ConfigConstants; import org.eclipse.jgit.lib.Constants; @@ -109,6 +110,22 @@ public abstract class PullRequestUtils { } /** + * Get owner of marker + * + * @param marker + * @return owner login name, may be null + */ + public static String getOwner(PullRequestMarker marker) { + if (marker == null) + return null; + org.eclipse.egit.github.core.Repository repo = marker.getRepo(); + if (repo == null) + return null; + User owner = repo.getOwner(); + return owner != null ? owner.getLogin() : null; + } + + /** * Are the given pull request's source and destination repositories the * same? * @@ -116,8 +133,12 @@ public abstract class PullRequestUtils { * @return true if same, false otherwise */ public static boolean isFromSameRepository(PullRequest request) { - return request.getHead().getRepo().getOwner() - .equals(request.getBase().getRepo().getOwner()); + if (request == null) + return false; + String headLogin = getOwner(request.getHead()); + if (headLogin == null) + return false; + return headLogin.equals(getOwner(request.getBase())); } /** @@ -130,8 +151,10 @@ public abstract class PullRequestUtils { */ public static RemoteConfig getRemote(Repository repo, PullRequest request) throws URISyntaxException { - return getRemoteConfig(repo, request.getHead().getRepo().getOwner() - .getLogin()); + if (isFromSameRepository(request)) + return getRemoteConfig(repo, Constants.DEFAULT_REMOTE_NAME); + else + return getRemoteConfig(repo, getOwner(request.getHead())); } /** |