mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[git] Push dialog: for new branch show commits which are not pushed yet
Show all commits that are in the given branch, but not in any remote branches in the given remote: `git log new_branch --not --remotes=origin` This fixes IDEA-83227.
This commit is contained in:
@@ -371,7 +371,6 @@ class GitPushLog extends JPanel implements TypeSafeDataProvider {
|
||||
GitBranch dest = branchInfo.getDestBranch();
|
||||
|
||||
GitPushBranchInfo.Type type = branchInfo.getType();
|
||||
final String showingRecentCommits = ", showing " + GitPusher.RECENT_COMMITS_NUMBER + " recent commits";
|
||||
String text = fromBranch.getName();
|
||||
SimpleTextAttributes attrs = SimpleTextAttributes.REGULAR_ATTRIBUTES;
|
||||
String additionalText = "";
|
||||
@@ -385,11 +384,11 @@ class GitPushLog extends JPanel implements TypeSafeDataProvider {
|
||||
case NEW_BRANCH:
|
||||
text += " -> +" + dest.getName();
|
||||
attrs = SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES;
|
||||
additionalText = " new branch will be created" + showingRecentCommits;
|
||||
additionalText = " new branch will be created.";
|
||||
break;
|
||||
case NO_TRACKED_OR_TARGET:
|
||||
attrs = SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES;
|
||||
additionalText = " no tracked branch. Use checkbox below to push branch to manually specified" + showingRecentCommits;
|
||||
additionalText = " no tracked branch. Use checkbox below to push branch to manually specified.";
|
||||
break;
|
||||
}
|
||||
renderer.append(text, attrs);
|
||||
|
||||
@@ -59,11 +59,6 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
*/
|
||||
public final class GitPusher {
|
||||
|
||||
/**
|
||||
* if diff-log is not available (new branch is created, for example), we show a few recent commits made on the branch
|
||||
*/
|
||||
static final int RECENT_COMMITS_NUMBER = 5;
|
||||
|
||||
@Deprecated
|
||||
static final GitRemoteBranch NO_TARGET_BRANCH = new GitStandardRemoteBranch(GitRemote.DOT, "", GitBranch.DUMMY_HASH);
|
||||
|
||||
@@ -187,7 +182,7 @@ public final class GitPusher {
|
||||
List<GitCommit> commits;
|
||||
GitPushBranchInfo.Type type;
|
||||
if (dest == NO_TARGET_BRANCH) {
|
||||
commits = collectRecentCommitsOnBranch(repository, source);
|
||||
commits = collectCommitsToPushForNewBranch(repository, source, dest.getRemote());
|
||||
type = GitPushBranchInfo.Type.NO_TRACKED_OR_TARGET;
|
||||
}
|
||||
else if (GitUtil.repoContainsRemoteBranch(repository, dest)) {
|
||||
@@ -195,7 +190,7 @@ public final class GitPusher {
|
||||
type = GitPushBranchInfo.Type.STANDARD;
|
||||
}
|
||||
else {
|
||||
commits = collectRecentCommitsOnBranch(repository, source);
|
||||
commits = collectCommitsToPushForNewBranch(repository, source, dest.getRemote());
|
||||
type = GitPushBranchInfo.Type.NEW_BRANCH;
|
||||
}
|
||||
commitsByBranch.put(source, new GitPushBranchInfo(source, dest, commits, type));
|
||||
@@ -204,8 +199,13 @@ public final class GitPusher {
|
||||
return new GitCommitsByBranch(commitsByBranch);
|
||||
}
|
||||
|
||||
private List<GitCommit> collectRecentCommitsOnBranch(GitRepository repository, GitBranch source) throws VcsException {
|
||||
return GitHistoryUtils.history(myProject, repository.getRoot(), "--max-count=" + RECENT_COMMITS_NUMBER, source.getName());
|
||||
@NotNull
|
||||
private static List<GitCommit> collectCommitsToPushForNewBranch(@NotNull GitRepository repository, @NotNull GitBranch source,
|
||||
@NotNull GitRemote remote) throws VcsException {
|
||||
// `git log new_branch --not --remotes=origin`
|
||||
// shows all commits that are in the given branch, but not in any remote branches in the given remote
|
||||
return GitHistoryUtils.history(repository.getProject(), repository.getRoot(),
|
||||
source.getName(), "--not", "--remotes=" + remote.getName());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user