mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[git] IDEA-75353 Let skip detached HEAD commit warning
This commit is contained in:
@@ -15,12 +15,14 @@
|
||||
*/
|
||||
package git4idea.checkin;
|
||||
|
||||
import com.intellij.CommonBundle;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Couple;
|
||||
@@ -281,7 +283,7 @@ public class GitCheckinHandlerFactory extends VcsCheckinHandlerFactory {
|
||||
private ReturnResult warnAboutDetachedHeadIfNeeded() {
|
||||
// Warning: commit on a detached HEAD
|
||||
DetachedRoot detachedRoot = getDetachedRoot();
|
||||
if (detachedRoot == null) {
|
||||
if (detachedRoot == null || !GitVcsSettings.getInstance(myProject).warnAboutDetachedHead()) {
|
||||
return ReturnResult.COMMIT;
|
||||
}
|
||||
|
||||
@@ -303,10 +305,38 @@ public class GitCheckinHandlerFactory extends VcsCheckinHandlerFactory {
|
||||
readMore("http://gitolite.com/detached-head.html", "Read more about detached HEAD");
|
||||
}
|
||||
|
||||
final int choice = Messages.showOkCancelDialog(myPanel.getComponent(), XmlStringUtil.wrapInHtml(message), title,
|
||||
"Cancel", "Commit",
|
||||
Messages.getWarningIcon());
|
||||
if (choice != Messages.OK) {
|
||||
DialogWrapper.DoNotAskOption dontAskAgain = new DialogWrapper.DoNotAskOption() {
|
||||
@Override
|
||||
public boolean isToBeShown() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setToBeShown(boolean toBeShown, int exitCode) {
|
||||
if (exitCode == Messages.OK) {
|
||||
GitVcsSettings.getInstance(myProject).setWarnAboutDetachedHead(toBeShown);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSaveOptionsOnCancel() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDoNotShowMessage() {
|
||||
return "Don't warn again";
|
||||
}
|
||||
};
|
||||
int choice = Messages.showOkCancelDialog(myProject, XmlStringUtil.wrapInHtml(message), title, "Commit",
|
||||
CommonBundle.getCancelButtonText(), Messages.getWarningIcon(), dontAskAgain);
|
||||
if (choice == Messages.OK) {
|
||||
return ReturnResult.COMMIT;
|
||||
} else {
|
||||
return ReturnResult.CLOSE_WINDOW;
|
||||
|
||||
@@ -91,7 +91,7 @@
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<grid id="4d15a" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="4d15a" layout-manager="GridLayoutManager" row-count="5" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
@@ -134,6 +134,15 @@
|
||||
<text value="Warn if &CRLF line separators are about to be committed"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="29d5c" class="javax.swing.JCheckBox" binding="myWarnAboutDetachedHead">
|
||||
<constraints>
|
||||
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<selected value="true"/>
|
||||
<text value="Warn when committing in detached HEAD or during rebase"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
|
||||
@@ -51,6 +51,7 @@ public class GitVcsPanel {
|
||||
private JBCheckBox mySyncBranchControl;
|
||||
private JCheckBox myAutoCommitOnCherryPick;
|
||||
private JBCheckBox myWarnAboutCrlf;
|
||||
private JCheckBox myWarnAboutDetachedHead;
|
||||
|
||||
public GitVcsPanel(@NotNull Project project) {
|
||||
myVcs = GitVcs.getInstance(project);
|
||||
@@ -121,6 +122,7 @@ public class GitVcsPanel {
|
||||
mySyncBranchControl.setSelected(settings.getSyncSetting() == DvcsBranchSync.SYNC);
|
||||
myAutoCommitOnCherryPick.setSelected(settings.isAutoCommitOnCherryPick());
|
||||
myWarnAboutCrlf.setSelected(settings.warnAboutCrlf());
|
||||
myWarnAboutDetachedHead.setSelected(settings.warnAboutDetachedHead());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,7 +136,8 @@ public class GitVcsPanel {
|
||||
!settings.autoUpdateIfPushRejected() == myAutoUpdateIfPushRejected.isSelected() ||
|
||||
((settings.getSyncSetting() == DvcsBranchSync.SYNC) != mySyncBranchControl.isSelected() ||
|
||||
settings.isAutoCommitOnCherryPick() != myAutoCommitOnCherryPick.isSelected() ||
|
||||
settings.warnAboutCrlf() != myWarnAboutCrlf.isSelected());
|
||||
settings.warnAboutCrlf() != myWarnAboutCrlf.isSelected() ||
|
||||
settings.warnAboutDetachedHead() != myWarnAboutDetachedHead.isSelected());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,6 +156,7 @@ public class GitVcsPanel {
|
||||
settings.setSyncSetting(mySyncBranchControl.isSelected() ? DvcsBranchSync.SYNC : DvcsBranchSync.DONT);
|
||||
settings.setAutoCommitOnCherryPick(myAutoCommitOnCherryPick.isSelected());
|
||||
settings.setWarnAboutCrlf(myWarnAboutCrlf.isSelected());
|
||||
settings.setWarnAboutDetachedHead(myWarnAboutDetachedHead.isSelected());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ public class GitVcsSettings implements PersistentStateComponent<GitVcsSettings.S
|
||||
public String RECENT_COMMON_BRANCH = null;
|
||||
public boolean AUTO_COMMIT_ON_CHERRY_PICK = false;
|
||||
public boolean WARN_ABOUT_CRLF = true;
|
||||
public boolean WARN_ABOUT_DETACHED_HEAD = true;
|
||||
public GitResetMode RESET_MODE = null;
|
||||
}
|
||||
|
||||
@@ -183,6 +184,14 @@ public class GitVcsSettings implements PersistentStateComponent<GitVcsSettings.S
|
||||
myState.WARN_ABOUT_CRLF = warn;
|
||||
}
|
||||
|
||||
public boolean warnAboutDetachedHead() {
|
||||
return myState.WARN_ABOUT_DETACHED_HEAD;
|
||||
}
|
||||
|
||||
public void setWarnAboutDetachedHead(boolean warn) {
|
||||
myState.WARN_ABOUT_DETACHED_HEAD = warn;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GitResetMode getResetMode() {
|
||||
return myState.RESET_MODE;
|
||||
|
||||
Reference in New Issue
Block a user