From c729c59cedff4e800c659e524081fbd1be8db3c1 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Thu, 22 Sep 2011 16:09:37 -0400
Subject: [PATCH] Rearranged federation status enum.
---
src/com/gitblit/utils/JGitUtils.java | 27 ++++++++++++++++++++++++++-
1 files changed, 26 insertions(+), 1 deletions(-)
diff --git a/src/com/gitblit/utils/JGitUtils.java b/src/com/gitblit/utils/JGitUtils.java
index b6b13ab..e61fea2 100644
--- a/src/com/gitblit/utils/JGitUtils.java
+++ b/src/com/gitblit/utils/JGitUtils.java
@@ -37,6 +37,10 @@
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;
import org.eclipse.jgit.diff.DiffEntry.ChangeType;
import org.eclipse.jgit.diff.DiffFormatter;
@@ -229,7 +233,28 @@
fetch.setCredentialsProvider(credentialsProvider);
}
fetch.setRefSpecs(specs);
- FetchResult result = fetch.call();
+ FetchResult fetchRes = fetch.call();
+ return fetchRes;
+ }
+
+ /**
+ * Reset HEAD to the latest remote tracking commit.
+ *
+ * @param repository
+ * @param remoteRef
+ * the remote tracking reference (e.g. origin/master)
+ * @return Ref
+ * @throws Exception
+ */
+ public static Ref resetHEAD(Repository repository, String remoteRef) throws Exception {
+ if (!remoteRef.startsWith(Constants.R_REMOTES)) {
+ remoteRef = Constants.R_REMOTES + remoteRef;
+ }
+ Git git = new Git(repository);
+ ResetCommand reset = git.reset();
+ reset.setMode(ResetType.SOFT);
+ reset.setRef(remoteRef);
+ Ref result = reset.call();
return result;
}
--
Gitblit v1.9.1