mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[git] IDEA-105577 Revert changes in listing commits in Git Push dialog.
This reverts:
* bebc84c2 IDEA-104846 Fix pushing new branch without new commits
* b200615c for new branch show commits which are not pushed yet
The right fix for this issue would be to identify probable remote for
the new branch before showing push dialog, but this change may be too
dangerous for 129, so just reverting the changes which led to the
problem.
Reverting it in master as well, since it will be fixed within push
dialog redesign.
(cherry picked from commit 025340e1ae8556745b7697e9e890c0a11c22ee4f)
This commit is contained in:
@@ -371,6 +371,7 @@ 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 = "";
|
||||
@@ -384,11 +385,11 @@ class GitPushLog extends JPanel implements TypeSafeDataProvider {
|
||||
case NEW_BRANCH:
|
||||
text += " -> +" + dest.getName();
|
||||
attrs = SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES;
|
||||
additionalText = " new branch will be created.";
|
||||
additionalText = " new branch will be created" + showingRecentCommits;
|
||||
break;
|
||||
case NO_TRACKED_OR_TARGET:
|
||||
attrs = SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES;
|
||||
additionalText = " no tracked branch. Use checkbox below to push branch to manually specified.";
|
||||
additionalText = " no tracked branch. Use checkbox below to push branch to manually specified" + showingRecentCommits;
|
||||
break;
|
||||
}
|
||||
renderer.append(text, attrs);
|
||||
|
||||
@@ -59,6 +59,11 @@ 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);
|
||||
|
||||
@@ -182,7 +187,7 @@ public final class GitPusher {
|
||||
List<GitCommit> commits;
|
||||
GitPushBranchInfo.Type type;
|
||||
if (dest == NO_TARGET_BRANCH) {
|
||||
commits = collectCommitsToPushForNewBranch(repository, source, dest.getRemote());
|
||||
commits = collectRecentCommitsOnBranch(repository, source);
|
||||
type = GitPushBranchInfo.Type.NO_TRACKED_OR_TARGET;
|
||||
}
|
||||
else if (GitUtil.repoContainsRemoteBranch(repository, dest)) {
|
||||
@@ -190,7 +195,7 @@ public final class GitPusher {
|
||||
type = GitPushBranchInfo.Type.STANDARD;
|
||||
}
|
||||
else {
|
||||
commits = collectCommitsToPushForNewBranch(repository, source, dest.getRemote());
|
||||
commits = collectRecentCommitsOnBranch(repository, source);
|
||||
type = GitPushBranchInfo.Type.NEW_BRANCH;
|
||||
}
|
||||
commitsByBranch.put(source, new GitPushBranchInfo(source, dest, commits, type));
|
||||
@@ -199,13 +204,8 @@ public final class GitPusher {
|
||||
return new GitCommitsByBranch(commitsByBranch);
|
||||
}
|
||||
|
||||
@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());
|
||||
private List<GitCommit> collectRecentCommitsOnBranch(GitRepository repository, GitBranch source) throws VcsException {
|
||||
return GitHistoryUtils.history(myProject, repository.getRoot(), "--max-count=" + RECENT_COMMITS_NUMBER, source.getName());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -239,12 +239,7 @@ public final class GitPusher {
|
||||
|
||||
GitCommitsByRepoAndBranch commits = pushInfo.getCommits();
|
||||
for (GitRepository repository : commits.getRepositories()) {
|
||||
GitCommitsByBranch commitsForRepo = commits.get(repository);
|
||||
GitLocalBranch sourceBranch = pushInfo.getPushSpecs().get(repository).getSource();
|
||||
if (commitsForRepo.get(sourceBranch).getType() == GitPushBranchInfo.Type.STANDARD &&
|
||||
commitsForRepo.getAllCommits().size() == 0) {
|
||||
// don't push repositories where there is nothing to push.
|
||||
// however, do push if new branch is created, even without commits
|
||||
if (commits.get(repository).getAllCommits().size() == 0) { // don't push repositories where there is nothing to push. Note that when a branch is created, several recent commits are stored in the pushInfo.
|
||||
continue;
|
||||
}
|
||||
GitPushRepoResult repoResult = pushRepository(pushInfo, commits, repository);
|
||||
|
||||
Reference in New Issue
Block a user