-
Notifications
You must be signed in to change notification settings - Fork 31
Feature lighter init #44
base: master
Are you sure you want to change the base?
Changes from 2 commits
12f0c00
c707228
7310e8a
14173b1
1062c2f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,8 @@ public class GitWagon extends StreamWagon { | |
private final boolean debug = Utils.getBooleanEnvironmentProperty("wagon.git.debug"); | ||
private final boolean safeCheckout = Utils.getBooleanEnvironmentProperty("wagon.git.safe.checkout"); | ||
private final boolean skipEmptyCommit = Utils.getBooleanEnvironmentProperty("wagon.git.skip.empty.commit"); | ||
private final boolean enableShallowFetch = Utils.getBooleanEnvironmentProperty("wagon.git.enable.shallow.fetch"); | ||
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. Can we invert logic here? What about disableShallowFetch thus we would assume it's enabled by default? |
||
private final String permanentRoot = Utils.getStringEnvironmentProperty("wagon.git.permanent.root"); | ||
|
||
private final ScmLogger log = new GitWagonLog(debug); | ||
|
||
|
@@ -116,15 +118,20 @@ protected void openConnectionInternal() throws ConnectionException, Authenticati | |
remote = url.substring(i + 3, url.length()); | ||
} | ||
|
||
File workDir = Utils.createCheckoutDirectory(remote); | ||
File workDir; | ||
if (permanentRoot != null && !"".equals(permanentRoot)) { | ||
workDir = Utils.createCheckoutDirectory(permanentRoot, true); | ||
} else { | ||
workDir = Utils.createCheckoutDirectory(remote, false); | ||
} | ||
|
||
if (!workDir.exists() || !workDir.isDirectory() || !workDir.canWrite()) | ||
throw new ConnectionException("Unable to create working directory"); | ||
|
||
if (safeCheckout) | ||
FileUtils.cleanDirectory(workDir); | ||
|
||
git = new GitBackend(workDir, remote, branch, log); | ||
git = new GitBackend(workDir, remote, branch, log, enableShallowFetch); | ||
git.pullAll(); | ||
} catch (Exception e) { | ||
throw new ConnectionException("Unable to pull git repository: " + e.getMessage(), e); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,9 +11,13 @@ public final class Utils { | |
private Utils() { | ||
} | ||
|
||
public static File createCheckoutDirectory(String path) throws GitException { | ||
|
||
File dir = new File(System.getProperty("java.io.tmpdir"), "wagon-git-" + hashPath(path)); | ||
public static File createCheckoutDirectory(String path, boolean isPermanent) throws GitException { | ||
File dir; | ||
if (isPermanent) { | ||
dir = new File(path); | ||
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'm not totally happy with this change. Let's forget path for a while, path is just a text transformation of the repo URI. What if the new argument just replaces the new File(java.io.tempdir) if present (not null)? 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'm not sure of what you mean =/
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. This new feature of providing a directory, interferes somehow, in a "semantic" way, with the "safe checkout" flag (http://synergian.github.io/wagon-git/troubleshooting.html), which wouldn't have any sense any more. I don't like to have features that interfere one with each other. That's what makes me unhappy :) I think it's much more elegant to provide a path, like you did. But I would like to remove the old flag so the features don't overlap. And also, as I spent quite some time writing the documentation, I'd like to have it updated to these changes. I'm not asking you to make those changes, I can. Sadly, I don't have the time right now, so they would have to wait. 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. Oh I forgot about this flag, you're totally right. 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. So, about this flag, should we keep it and enable it only when wagon.git.permanent.root is not set ? (ie. when wagon.git.permanent.root is set, wagon.git.safe.checkout is considered as false). 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'm sorry. I'm messing things up. I wrote that part of the code like 4 or 5 years ago. Forget that. Although, the name of the property should be Change that if you want. I'm okay if you don't. I'll just await for the documentation of the two new flags. |
||
} else { | ||
dir = new File(System.getProperty("java.io.tmpdir"), "wagon-git-" + hashPath(path)); | ||
} | ||
dir.mkdirs(); | ||
|
||
return dir; | ||
|
@@ -55,8 +59,10 @@ private static String hashPath(String path) throws GitException { | |
} | ||
|
||
public static boolean getBooleanEnvironmentProperty(String key) { | ||
|
||
return Boolean.parseBoolean(System.getProperty(key, "false")); | ||
} | ||
|
||
public static String getStringEnvironmentProperty(String key) { | ||
return System.getProperty(key, null); | ||
} | ||
} |
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.
Can you please remove unneeded imports?