Added rebase option to config

This commit is contained in:
Josh Larson
2017-03-28 08:51:19 -05:00
parent 83bdc39d41
commit 92e45a6299
2 changed files with 7 additions and 4 deletions

View File

@@ -61,12 +61,12 @@ public class GitInterface {
return "";
}
public boolean pullLastUpdate(String repository) throws IOException {
public boolean pullLastUpdate(String repository, boolean rebase) throws IOException {
try (Git git = new Git(FileRepositoryBuilder.create(new File(repository, ".git")))) {
PullResult res = git.pull()
.setRemote("origin")
.setRemoteBranchName("quality_assurance")
.setRebase(false)
.setRebase(rebase)
.setProgressMonitor(new CustomProgressMonitor()).call();
return res.isSuccessful();
} catch (GitAPIException e) {

View File

@@ -38,6 +38,7 @@ import me.joshlarson.json.JSONObject;
import com.projectswg.common.concurrency.PswgBasicScheduledThread;
import com.projectswg.common.control.LightspeedService;
import com.projectswg.common.debug.Log;
import com.projectswg.common.info.ConfigFile;
import com.projectswg.common.intents.PrepareStarshipIntent;
import com.projectswg.common.intents.RegisterHttpListenerIntent;
import com.projectswg.common.network.packets.PacketType;
@@ -86,10 +87,12 @@ public class ServerService extends LightspeedService {
for (ServerServerData server : servers) {
try {
String commit = git.getLastCommit(server.getDirectory());
if (commit.isEmpty())
commit = "?";
String lastCommit = server.getLastCommit();
server.setLastCommit(commit);
if (!lastCommit.equals(commit) && !lastCommit.equalsIgnoreCase("?")) {
if (!git.pullLastUpdate(server.getDirectory())) {
if (!lastCommit.equals(commit) && !lastCommit.equals("?") && !commit.equals("?")) {
if (!git.pullLastUpdate(server.getDirectory(), getConfig(ConfigFile.LIGHTSPEED).getBoolean("GIT-REBASE", false))) {
Log.e("Failed to pull latest update from %s", server.getName());
continue;
}