mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[git] executable detector: fix for default project
When there is no myPathToGit, and Settings is open before opening any project, GitVcs is not activated, and there is git.exe in the Settings instead of fairly detected executable. Solve it by returning to the previous logic: detect the executable right away in getPathToGit. Remove redundant getPathToGitAtStartup. Remove calling detect from GitVcs#activate since it will be automatically called from getPathToGit().
This commit is contained in:
@@ -363,11 +363,8 @@ public class GitVcs extends AbstractVcs<CommittedChangeList> {
|
||||
|
||||
private void checkExecutableAndVersion() {
|
||||
boolean executableIsAlreadyCheckedAndFine = false;
|
||||
String pathToGit = myAppSettings.getPathToGitAtStartup();
|
||||
if (pathToGit == null) {
|
||||
myAppSettings.setPathToGit(new GitExecutableDetector().detect());
|
||||
}
|
||||
else if (!pathToGit.contains(File.separator)) { // no path, just sole executable, with a hope that it is in path
|
||||
String pathToGit = myAppSettings.getPathToGit();
|
||||
if (!pathToGit.contains(File.separator)) { // no path, just sole executable, with a hope that it is in path
|
||||
// subject to redetect the path if executable validator fails
|
||||
if (!myExecutableValidator.isExecutableValid()) {
|
||||
myAppSettings.setPathToGit(new GitExecutableDetector().detect());
|
||||
|
||||
@@ -59,25 +59,12 @@ public class GitVcsApplicationSettings implements PersistentStateComponent<GitVc
|
||||
@NotNull
|
||||
public String getPathToGit() {
|
||||
if (myState.myPathToGit == null) {
|
||||
// can happen only if GitVcs#activate hasn't been called: it is when configurables are built, returning the default value.
|
||||
return GitExecutableDetector.DEFAULT_WIN_GIT;
|
||||
// detecting right away, this can be called from the default project without a call to GitVcs#activate()
|
||||
myState.myPathToGit = new GitExecutableDetector().detect();
|
||||
}
|
||||
return myState.myPathToGit;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>This method differs from {@link #getPathToGit()} only in the @Nullable annotation: initially the path can be null,
|
||||
* but after VCS is initialized for the first time, correct path is set in {@link git4idea.GitVcs} and is never null,
|
||||
* so we want the @NotNull annotation there.</p>
|
||||
* <p>This method should be called only from {@link git4idea.GitVcs#activate()}.</p>
|
||||
*
|
||||
* @return Path to Git or null if the path was not written to the config yet.
|
||||
*/
|
||||
@Nullable
|
||||
public String getPathToGitAtStartup() {
|
||||
return myState.myPathToGit;
|
||||
}
|
||||
|
||||
public void setPathToGit(String pathToGit) {
|
||||
myState.myPathToGit = pathToGit;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user