summaryrefslogtreecommitdiffstats
path: root/src/com/gitblit/utils/JGitUtils.java
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2011-09-26 15:33:19 -0400
committerJames Moger <james.moger@gitblit.com>2011-09-26 15:33:19 -0400
commitf6740d55ff80bc6e16da5c3df0ee1ba2235d6629 (patch)
tree55e3fe4e47dc6b4bd74636a95e833d6dc1c7dd7e /src/com/gitblit/utils/JGitUtils.java
parentd7fb202c122faa90a75717cbd66791d3879b5776 (diff)
downloadgitblit-f6740d55ff80bc6e16da5c3df0ee1ba2235d6629.tar.gz
gitblit-f6740d55ff80bc6e16da5c3df0ee1ba2235d6629.zip
Implemented a Federation Client. Bare clone tweaks. Documentation.
Diffstat (limited to 'src/com/gitblit/utils/JGitUtils.java')
-rw-r--r--src/com/gitblit/utils/JGitUtils.java21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/com/gitblit/utils/JGitUtils.java b/src/com/gitblit/utils/JGitUtils.java
index faca9cb6..bfbc6240 100644
--- a/src/com/gitblit/utils/JGitUtils.java
+++ b/src/com/gitblit/utils/JGitUtils.java
@@ -37,8 +37,6 @@ import java.util.zip.ZipOutputStream;
import org.eclipse.jgit.api.CloneCommand;
import org.eclipse.jgit.api.FetchCommand;
import org.eclipse.jgit.api.Git;
-import org.eclipse.jgit.api.PullCommand;
-import org.eclipse.jgit.api.PullResult;
import org.eclipse.jgit.api.ResetCommand;
import org.eclipse.jgit.api.ResetCommand.ResetType;
import org.eclipse.jgit.diff.DiffEntry;
@@ -142,6 +140,7 @@ public class JGitUtils {
* Encapsulates the result of cloning or pulling from a repository.
*/
public static class CloneResult {
+ public String name;
public FetchResult fetchResult;
public boolean createdRepository;
}
@@ -175,12 +174,22 @@ public class JGitUtils {
* @return CloneResult
* @throws Exception
*/
- public static CloneResult cloneRepository(File repositoriesFolder, String name, String fromUrl, boolean bare,
- CredentialsProvider credentialsProvider) throws Exception {
+ public static CloneResult cloneRepository(File repositoriesFolder, String name, String fromUrl,
+ boolean bare, CredentialsProvider credentialsProvider) throws Exception {
CloneResult result = new CloneResult();
- if (bare && !name.toLowerCase().endsWith(Constants.DOT_GIT_EXT)) {
- name += Constants.DOT_GIT_EXT;
+ if (bare) {
+ // bare repository, ensure .git suffix
+ if (!name.toLowerCase().endsWith(Constants.DOT_GIT_EXT)) {
+ name += Constants.DOT_GIT_EXT;
+ }
+ } else {
+ // normal repository, strip .git suffix
+ if (name.toLowerCase().endsWith(Constants.DOT_GIT_EXT)) {
+ name = name.substring(0, name.indexOf(Constants.DOT_GIT_EXT));
+ }
}
+ result.name = name;
+
File folder = new File(repositoriesFolder, name);
if (folder.exists()) {
File gitDir = FileKey.resolve(new File(repositoriesFolder, name), FS.DETECTED);