Move resolveGrandparentFile() to the base class for wider use
Change-Id: I67ec732ea2e5345a6946783f0c5ef60c07ce254e Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
parent
686124bec3
commit
8025443db4
|
@ -507,6 +507,21 @@ public File gitPrefix() {
|
||||||
/** @return the $prefix directory C Git would use. */
|
/** @return the $prefix directory C Git would use. */
|
||||||
protected abstract File discoverGitPrefix();
|
protected abstract File discoverGitPrefix();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param grandchild
|
||||||
|
* @return the parent directory of this file's parent directory or
|
||||||
|
* {@code null} in case there's no grandparent directory
|
||||||
|
* @since 4.0
|
||||||
|
*/
|
||||||
|
protected static File resolveGrandparentFile(File grandchild) {
|
||||||
|
if (grandchild != null) {
|
||||||
|
File parent = grandchild.getParentFile();
|
||||||
|
if (parent != null)
|
||||||
|
return parent.getParentFile();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the $prefix directory C Git uses.
|
* Set the $prefix directory C Git uses.
|
||||||
*
|
*
|
||||||
|
|
|
@ -138,7 +138,7 @@ protected File discoverGitPrefix() {
|
||||||
String path = SystemReader.getInstance().getenv("PATH"); //$NON-NLS-1$
|
String path = SystemReader.getInstance().getenv("PATH"); //$NON-NLS-1$
|
||||||
File gitExe = searchPath(path, "git"); //$NON-NLS-1$
|
File gitExe = searchPath(path, "git"); //$NON-NLS-1$
|
||||||
if (gitExe != null)
|
if (gitExe != null)
|
||||||
return gitExe.getParentFile().getParentFile();
|
return resolveGrandparentFile(gitExe);
|
||||||
|
|
||||||
if (SystemReader.getInstance().isMacOS()) {
|
if (SystemReader.getInstance().isMacOS()) {
|
||||||
// On MacOSX, PATH is shorter when Eclipse is launched from the
|
// On MacOSX, PATH is shorter when Eclipse is launched from the
|
||||||
|
@ -150,10 +150,7 @@ protected File discoverGitPrefix() {
|
||||||
Charset.defaultCharset().name());
|
Charset.defaultCharset().name());
|
||||||
if (w == null || w.length() == 0)
|
if (w == null || w.length() == 0)
|
||||||
return null;
|
return null;
|
||||||
File parentFile = new File(w).getParentFile();
|
return resolveGrandparentFile(new File(w));
|
||||||
if (parentFile == null)
|
|
||||||
return null;
|
|
||||||
return parentFile.getParentFile();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -128,15 +128,6 @@ protected File discoverGitPrefix() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static File resolveGrandparentFile(File grandchild) {
|
|
||||||
if (grandchild != null) {
|
|
||||||
File parent = grandchild.getParentFile();
|
|
||||||
if (parent != null)
|
|
||||||
return parent.getParentFile();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected File userHomeImpl() {
|
protected File userHomeImpl() {
|
||||||
String home = SystemReader.getInstance().getenv("HOME"); //$NON-NLS-1$
|
String home = SystemReader.getInstance().getenv("HOME"); //$NON-NLS-1$
|
||||||
|
|
Loading…
Reference in New Issue