From 54b5cce0dbcaf0f4bb19302afbe38cf16cd93055 Mon Sep 17 00:00:00 2001 From: Ivan Semenov Date: Wed, 25 Oct 2017 13:44:38 +0300 Subject: [PATCH] IDEA-144811 Allow designating project-level git executable override --- .../intellij/dvcs/ui/DvcsBundle.properties | 2 + .../src/messages/VcsBundle.properties | 5 + plugins/git4idea/src/git4idea/GitVcs.java | 2 +- .../src/git4idea/config/GitVcsPanel.form | 17 +++- .../src/git4idea/config/GitVcsPanel.java | 92 ++++++++++++++----- .../src/git4idea/config/GitVcsSettings.java | 11 +++ 6 files changed, 100 insertions(+), 29 deletions(-) diff --git a/platform/dvcs-impl/src/com/intellij/dvcs/ui/DvcsBundle.properties b/platform/dvcs-impl/src/com/intellij/dvcs/ui/DvcsBundle.properties index 6f0633e96c48..aca796920baf 100644 --- a/platform/dvcs-impl/src/com/intellij/dvcs/ui/DvcsBundle.properties +++ b/platform/dvcs-impl/src/com/intellij/dvcs/ui/DvcsBundle.properties @@ -22,3 +22,5 @@ push.force.confirmation.text = You''re going to force push{0}. It may overwrite sync.setting=Execute branch operations on all roots sync.setting.description=If selected, you would be able to checkout, compare, delete and create new branches in all {0} \ roots with a single action. It will also affect behavior of the push dialog. + +executable.path.project.override=Set this path only for current project \ No newline at end of file diff --git a/platform/platform-resources-en/src/messages/VcsBundle.properties b/platform/platform-resources-en/src/messages/VcsBundle.properties index d31e1dad7041..34110b1ed74f 100644 --- a/platform/platform-resources-en/src/messages/VcsBundle.properties +++ b/platform/platform-resources-en/src/messages/VcsBundle.properties @@ -580,3 +580,8 @@ paths.affected.in.revision=Paths Affected in Revision {0} refresh.failed.message=Refresh failed: {0} file.status.name.up.to.date.immediate.children=Have immediate changed children file.status.name.up.to.date.recursive.children=Have changed descendants + +executable.project.override.reset.title=Project Executable +executable.project.override.reset.message=Path to executable configured for this project can be set as the global path for all projects or reverted to the current global executable +executable.project.override.reset.globalize=Set as Global +executable.project.override.reset.revert=Revert diff --git a/plugins/git4idea/src/git4idea/GitVcs.java b/plugins/git4idea/src/git4idea/GitVcs.java index 377a50074301..e70317c1faed 100644 --- a/plugins/git4idea/src/git4idea/GitVcs.java +++ b/plugins/git4idea/src/git4idea/GitVcs.java @@ -151,7 +151,7 @@ public class GitVcs extends AbstractVcs { myRollbackEnvironment = gitRollbackEnvironment; myGitExecutableManager = gitExecutableManager; myRevSelector = new GitRevisionSelector(); - myConfigurable = new GitVcsConfigurable(myProject, gitProjectSettings, sharedSettings); + myConfigurable = new GitVcsConfigurable(gitSettings, myProject, gitProjectSettings, sharedSettings); myUpdateEnvironment = new GitUpdateEnvironment(myProject, gitProjectSettings); myCommittedChangeListProvider = new GitCommittedChangeListProvider(myProject); myOutgoingChangesProvider = new GitOutgoingChangesProvider(myProject); diff --git a/plugins/git4idea/src/git4idea/config/GitVcsPanel.form b/plugins/git4idea/src/git4idea/config/GitVcsPanel.form index dd439208e2ca..9f5a3948f410 100644 --- a/plugins/git4idea/src/git4idea/config/GitVcsPanel.form +++ b/plugins/git4idea/src/git4idea/config/GitVcsPanel.form @@ -8,7 +8,7 @@ - + @@ -30,7 +30,7 @@ - + @@ -40,7 +40,7 @@ - + @@ -66,7 +66,7 @@ - + @@ -84,6 +84,15 @@ + + + + + + + + + diff --git a/plugins/git4idea/src/git4idea/config/GitVcsPanel.java b/plugins/git4idea/src/git4idea/config/GitVcsPanel.java index d136001983b2..c501e24559eb 100644 --- a/plugins/git4idea/src/git4idea/config/GitVcsPanel.java +++ b/plugins/git4idea/src/git4idea/config/GitVcsPanel.java @@ -28,11 +28,14 @@ import com.intellij.openapi.ui.Messages; import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.openapi.util.ThrowableComputable; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.openapi.vcs.VcsBundle; import com.intellij.ui.EnumComboBoxModel; import com.intellij.ui.ListCellRendererWrapper; import com.intellij.ui.components.JBCheckBox; import com.intellij.ui.components.JBLabel; +import com.intellij.ui.components.JBTextField; import com.intellij.ui.components.fields.ExpandableTextField; +import com.intellij.util.ObjectUtils; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.execution.ParametersListUtil; import com.intellij.util.ui.UIUtil; @@ -40,6 +43,7 @@ import git4idea.GitVcs; import git4idea.i18n.GitBundle; import git4idea.repo.GitRepositoryManager; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.event.ActionEvent; @@ -47,6 +51,7 @@ import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.util.List; +import java.util.Objects; /** * Git VCS configuration panel @@ -56,12 +61,14 @@ public class GitVcsPanel implements ConfigurableUi testExecutable()); myGitField.addBrowseFolderListener(GitBundle.getString("find.git.title"), GitBundle.getString("find.git.description"), project, FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor()); + myProjectGitPathCheckBox.addActionListener(e -> handleProjectOverrideStateChanged()); if (!project.isDefault()) { final GitRepositoryManager repositoryManager = GitRepositoryManager.getInstance(project); mySyncControl.setVisible(repositoryManager != null && repositoryManager.moreThanOneRoot()); @@ -106,22 +109,16 @@ public class GitVcsPanel implements ConfigurableUi() { @Override public GitVersion compute() throws Exception { return GitVersion.identifyVersion(executable); } - }, "Testing Git Executable...", true, myVcs.getProject()); + }, "Testing Git Executable...", true, myProject); } catch (ProcessCanceledException pce) { return; @@ -144,8 +141,30 @@ public class GitVcsPanel implements ConfigurableUi GitVcs.getInstance(myProject).checkVersion(), + "Testing Git Executable...", true, null, + myRootPanel); } @NotNull @@ -219,6 +262,7 @@ public class GitVcsPanel implements ConfigurableUi(UpdateMethod.class)); myUpdateMethodComboBox.setRenderer(new ListCellRendererWrapper() { diff --git a/plugins/git4idea/src/git4idea/config/GitVcsSettings.java b/plugins/git4idea/src/git4idea/config/GitVcsSettings.java index 224368f285c3..057892546b41 100644 --- a/plugins/git4idea/src/git4idea/config/GitVcsSettings.java +++ b/plugins/git4idea/src/git4idea/config/GitVcsSettings.java @@ -60,6 +60,8 @@ public class GitVcsSettings implements PersistentStateComponent PREVIOUS_COMMIT_AUTHORS = new ArrayList<>(); public GitVcsApplicationSettings.SshExecutable SSH_EXECUTABLE = GitVcsApplicationSettings.SshExecutable.IDEA_SSH; @@ -146,6 +148,15 @@ public class GitVcsSettings implements PersistentStateComponent