-
Notifications
You must be signed in to change notification settings - Fork 926
Git push dialog: Sort active git branch to top and select it automatically #9385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
OndroMih
wants to merge
1
commit into
apache:master
Choose a base branch
from
OndroMih:git-push-dialog-branch-selection
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,11 +44,17 @@ public abstract class PushMapping extends ItemSelector.Item { | |
| private static final String COLOR_MODIFIED = GitUtils.getColorString(AnnotationColorProvider.getInstance().MODIFIED_FILE.getActualColor()); | ||
| private static final String COLOR_REMOVED = GitUtils.getColorString(AnnotationColorProvider.getInstance().REMOVED_FILE.getActualColor()); | ||
| private static final String COLOR_CONFLICT = GitUtils.getColorString(AnnotationColorProvider.getInstance().CONFLICT_FILE.getActualColor()); | ||
|
|
||
| protected PushMapping (String localName, String localId, String remoteName, boolean conflict, boolean preselected, boolean updateNeeded) { | ||
| private final boolean active; | ||
|
|
||
| protected PushMapping (String localName, String localId, String remoteName, boolean conflict, boolean preselected, boolean updateNeeded, boolean active) { | ||
| super(preselected, localName == null || conflict); | ||
| this.localName = localName; | ||
| this.remoteName = remoteName == null ? localName : remoteName; | ||
| this.active = active; | ||
| String displayName = localName; | ||
| if (active && localName != null) { | ||
| displayName = localName + " (active)"; //NOI18N | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the |
||
| } | ||
| if (localName == null) { | ||
| // to remove | ||
| label = MessageFormat.format(BRANCH_DELETE_MAPPING_LABEL, remoteName, "<font color=\"" + COLOR_REMOVED + "\">R</font>"); //NOI18N | ||
|
|
@@ -61,7 +67,7 @@ protected PushMapping (String localName, String localId, String remoteName, bool | |
| }); //NOI18N | ||
| } else if (remoteName == null) { | ||
| // added | ||
| label = MessageFormat.format(BRANCH_MAPPING_LABEL, localName, localName, "<font color=\"" + COLOR_NEW + "\">A</font>"); //NOI18N | ||
| label = MessageFormat.format(BRANCH_MAPPING_LABEL, displayName, localName, "<font color=\"" + COLOR_NEW + "\">A</font>"); //NOI18N | ||
| tooltip = NbBundle.getMessage( | ||
| PushBranchesStep.class, | ||
| "LBL_PushBranchMapping.description", //NOI18N | ||
|
|
@@ -71,7 +77,7 @@ protected PushMapping (String localName, String localId, String remoteName, bool | |
| }); //NOI18N | ||
| } else if (conflict) { | ||
| // modified | ||
| label = MessageFormat.format(BRANCH_MAPPING_LABEL, localName, remoteName, "<font color=\"" + COLOR_CONFLICT + "\">C</font>"); //NOI18N | ||
| label = MessageFormat.format(BRANCH_MAPPING_LABEL, displayName, remoteName, "<font color=\"" + COLOR_CONFLICT + "\">C</font>"); //NOI18N | ||
| tooltip = NbBundle.getMessage( | ||
| PushBranchesStep.class, | ||
| "LBL_PushBranchMapping.Mode.conflict.description", //NOI18N | ||
|
|
@@ -80,7 +86,7 @@ protected PushMapping (String localName, String localId, String remoteName, bool | |
| }); | ||
| } else if (updateNeeded) { | ||
| // modified | ||
| label = MessageFormat.format(BRANCH_MAPPING_LABEL, localName, remoteName, "<font color=\"" + COLOR_MODIFIED + "\">U</font>"); //NOI18N | ||
| label = MessageFormat.format(BRANCH_MAPPING_LABEL, displayName, remoteName, "<font color=\"" + COLOR_MODIFIED + "\">U</font>"); //NOI18N | ||
| tooltip = NbBundle.getMessage( | ||
| PushBranchesStep.class, | ||
| "LBL_PushBranchMapping.description", //NOI18N | ||
|
|
@@ -90,7 +96,7 @@ protected PushMapping (String localName, String localId, String remoteName, bool | |
| }); | ||
| } else { | ||
| // up to date | ||
| label = MessageFormat.format(BRANCH_MAPPING_LABEL_UPTODATE, localName, remoteName); | ||
| label = MessageFormat.format(BRANCH_MAPPING_LABEL_UPTODATE, displayName, remoteName); | ||
| tooltip = NbBundle.getMessage(PushBranchesStep.class, | ||
| "LBL_PushBranchMapping.Mode.uptodate.description", //NOI18N | ||
| remoteName); | ||
|
|
@@ -118,13 +124,28 @@ public final String getLocalName () { | |
| return localName; | ||
| } | ||
|
|
||
| public final boolean isActive () { | ||
| return active; | ||
| } | ||
|
|
||
| @Override | ||
| public int compareTo (Item t) { | ||
| if (t == null) { | ||
| return 1; | ||
| } | ||
| if (t instanceof PushMapping) { | ||
| PushMapping other = (PushMapping) t; | ||
| if (isActive() != other.isActive()) { | ||
| return isActive() ? -1 : 1; | ||
| } | ||
| if (isActive()) { | ||
| if (this instanceof PushBranchMapping && other instanceof PushTagMapping) { | ||
| return -1; | ||
| } | ||
| if (this instanceof PushTagMapping && other instanceof PushBranchMapping) { | ||
| return 1; | ||
| } | ||
| } | ||
| if (isDestructive() && other.isDestructive()) { | ||
| return remoteName.compareTo(other.remoteName); | ||
| } else if (isDestructive() && !other.isDestructive()) { | ||
|
|
@@ -162,7 +183,7 @@ public PushBranchMapping (String remoteBranchName, String remoteBranchId, boolea | |
| * Denotes a branch to be deleted in a remote repository | ||
| */ | ||
| public PushBranchMapping (String remoteBranchName, String remoteBranchId, boolean preselected, boolean updateNeeded) { | ||
| super(null, null, remoteBranchName, false, preselected, updateNeeded); | ||
| super(null, null, remoteBranchName, false, preselected, updateNeeded, false); | ||
| this.localBranch = null; | ||
| this.remoteBranchName = remoteBranchName; | ||
| this.remoteBranchId = remoteBranchId; | ||
|
|
@@ -177,7 +198,8 @@ public PushBranchMapping (String remoteBranchName, String remoteBranchId, GitBra | |
| remoteBranchName, | ||
| conflict, | ||
| preselected, | ||
| updateNeeded); | ||
| updateNeeded, | ||
| localBranch != null && localBranch.isActive()); | ||
| this.localBranch = localBranch; | ||
| this.remoteBranchName = remoteBranchName; | ||
| this.remoteBranchId = remoteBranchId; | ||
|
|
@@ -243,8 +265,8 @@ public static final class PushTagMapping extends PushMapping { | |
| * | ||
| * @param remoteName remote tag name | ||
| */ | ||
| public PushTagMapping(String remoteName) { | ||
| super(null, null, remoteName, false, false, remoteName != null); | ||
| public PushTagMapping(String remoteName, boolean active) { | ||
| super(null, null, remoteName, false, false, remoteName != null, active); | ||
| this.tag = null; | ||
| this.isUpdate = remoteName != null; | ||
| this.remoteTagName = remoteName; | ||
|
|
@@ -256,8 +278,8 @@ public PushTagMapping(String remoteName) { | |
| * @param tag representation of a local tag | ||
| * @param remoteName remote tag name, can be null. If null than we create tag. | ||
| */ | ||
| public PushTagMapping (GitTag tag, String remoteName) { | ||
| super("tags/" + tag.getTagName(), tag.getTaggedObjectId(), remoteName, false, false, remoteName != null); //NOI18N | ||
| public PushTagMapping (GitTag tag, String remoteName, boolean active) { | ||
| super("tags/" + tag.getTagName(), tag.getTaggedObjectId(), remoteName, false, false, remoteName != null, active); //NOI18N | ||
| this.tag = tag; | ||
| this.isUpdate = remoteName != null; | ||
| this.remoteTagName = remoteName; | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the
branch.isActive()check should only be considered ifremoteBranchisnull. IfremoteBranchis non-null, the logic already does the right thing, only new branches need to be considered.Currently this can happen:
The checked state for the active branch makes no sense, as there is nothing to push.