org.eclipse.jgit.api.PullResult Java Examples

The following examples show how to use org.eclipse.jgit.api.PullResult. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GitUtils.java    From gitPic with MIT License 8 votes vote down vote up
public static void pull(Repository repository) {
    Git git = new Git(repository);
    try {
        PullResult result = git.pull().call();
        FetchResult fetchResult = result.getFetchResult();
        MergeResult mergeResult = result.getMergeResult();
        if (fetchResult.getMessages() != null && !fetchResult.getMessages().isEmpty()) {
            logger.info(fetchResult.getMessages());
        }
        logger.info(mergeResult.getMergeStatus().toString());
        if (!mergeResult.getMergeStatus().isSuccessful()) {
            throw new TipException(mergeResult.getMergeStatus().toString());
        }
    } catch (GitAPIException e) {
        logger.error(e.getMessage(), e);
        throw new TipException("git commit 异常");
    }
}
 
Example #2
Source File: GitUtilsTest.java    From submarine with Apache License 2.0 6 votes vote down vote up
@Test
public void pull() {
  if (token == null) {
    LOG.warn("Token not set!");
    return;
  } else {
    gitUtils.add(LOCALPATH, "/log4j.properties");
    gitUtils.commit(LOCALPATH, "add new file.");
    Iterable<PushResult> iterable = gitUtils.push(LOCALPATH, token, REMOTE_PATH);
    assertEquals(1, Lists.newArrayList(iterable).size());

    PullResult pullResult = gitUtils.pull(LOCALPATH, token, "master");
    assertEquals(1, pullResult.getFetchResult().getTrackingRefUpdates().size());

    gitUtils.rm(LOCALPATH, "/log4j.properties");
    gitUtils.commit(LOCALPATH, "add new file.");
    gitUtils.push(LOCALPATH, token, REMOTE_PATH);
  }
}
 
Example #3
Source File: UIGitTest.java    From hop with Apache License 2.0 6 votes vote down vote up
@Test
public void testPull() throws Exception {
  // source: db2, target: db
  setupRemote();
  Git git2 = new Git( db2 );

  // put some file in the source repo and sync
  File sourceFile = new File( db2.getWorkTree(), "SomeFile.txt" );
  FileUtils.writeStringToFile( sourceFile, "Hello world" );
  git2.add().addFilepattern( "SomeFile.txt" ).call();
  git2.commit().setMessage( "Initial commit for source" ).call();
  PullResult pullResult = git.pull().call();

  // change the source file
  FileUtils.writeStringToFile( sourceFile, "Another change" );
  git2.add().addFilepattern( "SomeFile.txt" ).call();
  git2.commit().setMessage( "Some change in remote" ).call();
  git2.close();

  assertTrue( uiGit.pull() );
}
 
Example #4
Source File: PullTask.java    From ant-git-tasks with Apache License 2.0 6 votes vote down vote up
@Override
public void doExecute() {
        try {
                PullCommand pullCommand = git.pull().setRebase(rebase);

                if (getProgressMonitor() != null) {
                        pullCommand.setProgressMonitor(getProgressMonitor());
                }

                setupCredentials(pullCommand);
                PullResult pullResult = pullCommand.call();

                if (!pullResult.isSuccessful()) {
                        FetchResult fetchResult = pullResult.getFetchResult();
                        GitTaskUtils.validateTrackingRefUpdates(MESSAGE_PULLED_FAILED, fetchResult.getTrackingRefUpdates());
                        MergeStatus mergeStatus = pullResult.getMergeResult().getMergeStatus();

                        if (!mergeStatus.isSuccessful()) {
                                throw new BuildException(String.format(MESSAGE_PULLED_FAILED_WITH_STATUS, mergeStatus.name()));
                        }
                }
        }
        catch (Exception e) {
                throw new GitBuildException(String.format(MESSAGE_PULLED_FAILED_WITH_URI, getUri()), e);
        }
}
 
Example #5
Source File: GitProctorCore.java    From proctor with Apache License 2.0 6 votes vote down vote up
public void refresh() {
    workspaceProvider.synchronizedOperation(new Callable<Void>() {
        @Override
        public Void call() {
            try {
                /* git pull is preferable since it's more efficient */
                LOGGER.debug("Started refresh with git pull");
                final PullResult result = getGit().pull().setProgressMonitor(PROGRESS_MONITOR).setRebase(true).setCredentialsProvider(user).call();
                if (!result.isSuccessful()) {
                    /* if git pull failed, use git reset */
                    LOGGER.info("refresh failed. Running undo local changes");
                    undoLocalChanges();
                }
                LOGGER.debug("Finished refresh");
            } catch (final Exception e) {
                LOGGER.error("Error when refreshing git directory " + workspaceProvider.getRootDirectory(), e);
            }
            return null;
        }
    });
}
 
Example #6
Source File: GitDirectoryRefresher.java    From proctor with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
    workspaceProvider.synchronizedOperation(new Callable<Void>() {
        @Override
        public Void call() {
            try {

                final PullResult result = gitProctorCore.getGit()
                        .pull()
                        .setProgressMonitor(PROGRESS_MONITOR)
                        .setRebase(true)
                        .setCredentialsProvider(user)
                        .setTimeout(GitProctorUtils.DEFAULT_GIT_PULL_PUSH_TIMEOUT_SECONDS)
                        .call();
                if (!result.isSuccessful()) {
                    /** if git pull failed, use git reset **/
                    gitProctorCore.undoLocalChanges();
                }
            } catch (final Exception e) {
                LOGGER.error("Error when refreshing git directory " + getDirectoryPath(), e);
            }
            return null;
        }
    });

}
 
Example #7
Source File: GitCloneTest.java    From orion.server with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void testGetCloneAndPull() throws Exception {
	// see bug 339254
	createWorkspace(SimpleMetaStore.DEFAULT_WORKSPACE_NAME);
	String workspaceId = getWorkspaceId(workspaceLocation);

	JSONObject project = createProjectOrLink(workspaceLocation, getMethodName().concat("Project"), null);
	String contentLocation = clone(workspaceId, project).getString(ProtocolConstants.KEY_CONTENT_LOCATION);

	JSONArray clonesArray = listClones(workspaceId, null);
	assertEquals(1, clonesArray.length());

	Repository r = getRepositoryForContentLocation(contentLocation);

	// overwrite user settings, do not rebase when pulling, see bug 372489
	StoredConfig cfg = r.getConfig();
	cfg.setBoolean(ConfigConstants.CONFIG_BRANCH_SECTION, Constants.MASTER, ConfigConstants.CONFIG_KEY_REBASE, false);
	cfg.save();

	// TODO: replace with RESTful API when ready, see bug 339114
	Git git = Git.wrap(r);
	PullResult pullResult = git.pull().call();
	assertEquals(pullResult.getMergeResult().getMergeStatus(), MergeStatus.ALREADY_UP_TO_DATE);
	assertEquals(RepositoryState.SAFE, git.getRepository().getRepositoryState());
}
 
Example #8
Source File: GitRepositoryExampleService.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
protected IStatus updateRepository(IProgressMonitor monitor) {
	String repoURL = getPreference(ExamplesPreferenceConstants.REMOTE_LOCATION);

	java.nio.file.Path storageLocation = getStorageLocation();
	try {
		Git git = Git.open(storageLocation.toFile());
		PullResult result = git.pull().setProgressMonitor(new EclipseGitProgressTransformer(monitor)).call();
		if (!result.isSuccessful()) {
			return new Status(IStatus.ERROR, ExampleActivator.PLUGIN_ID,
					"Unable to update repository " + repoURL + "!");
		}
	} catch (GitAPIException | IOException e) {
		return new Status(IStatus.ERROR, ExampleActivator.PLUGIN_ID,
				"Unable to update repository " + repoURL + "!");
	}
	return Status.OK_STATUS;
}
 
Example #9
Source File: GitMergeUtil.java    From MergeProcessor with Apache License 2.0 5 votes vote down vote up
/**
 * {@code git pull}
 */
private void pull() {
	try {
		final PullResult call = repo.pull().call();
		if (!call.isSuccessful()) {
			exception = new MergeUnitException(
					String.format("Could not pull from remote repository '%s'", repo)); //$NON-NLS-1$
		}
	} catch (GitAPIException e) {
		exception = new MergeUnitException(String.format("Could not push the local repository '%s'.", repo), e); //$NON-NLS-1$
	}
}
 
Example #10
Source File: GitUtils.java    From jphp with Apache License 2.0 5 votes vote down vote up
public static ArrayMemory valueOf(PullResult call) {
    ArrayMemory memory = new ArrayMemory();
    memory.refOfIndex("success").assign(call.isSuccessful());
    memory.refOfIndex("fetchedFrom").assign(call.getFetchedFrom());
    memory.refOfIndex("fetch").assign(valueOf(call.getFetchResult()));
    memory.refOfIndex("merge").assign(call.getMergeResult() == null ? Memory.NULL : valueOf(call.getMergeResult()));

    return memory;
}
 
Example #11
Source File: GitSynchronizeWindow.java    From XACML with MIT License 5 votes vote down vote up
protected void synchronize() {
	//
	// Grab our working repository
	//
	Path repoPath = ((XacmlAdminUI)getUI()).getUserGitPath();
	try {
		final Git git = Git.open(repoPath.toFile());
		
		PullResult result = git.pull().call();
		FetchResult fetch = result.getFetchResult();
		MergeResult merge = result.getMergeResult();
		RebaseResult rebase = result.getRebaseResult();
		if (result.isSuccessful()) {
			//
			// TODO add more notification
			//
			this.textAreaResults.setValue("Successful!");
		} else {
			//
			// TODO
			//
			this.textAreaResults.setValue("Failed.");
		}
	} catch (IOException | GitAPIException e) {
		e.printStackTrace();
	}
	this.buttonSynchronize.setCaption("Ok");
}
 
Example #12
Source File: RepositorioCartasServico.java    From portal-de-servicos with MIT License 5 votes vote down vote up
@SneakyThrows
public boolean contemAtualizacoes() {
    if (caminhoLocal == null) {
        caminhoLocal = clonarRepositorio(criarDiretorioTemporario());
        caminhoLocal.deleteOnExit();
        return true;

    }

    log.debug("Atualizando repositório de cartas de serviço de {} para {}", urlRepositorio, caminhoLocal);
    try (Git repositorio = Git.open(caminhoLocal)) {
        String oldHead = repositorio.getRepository().getRef(R_HEADS + MASTER).getObjectId().getName();

        PullResult result = repositorio.pull()
                .setProgressMonitor(new LogstashProgressMonitor(log))
                .setStrategy(THEIRS)
                .call();

        if (!result.isSuccessful()) {
            log.error("Erro ao atualizar repositório: {}", result);
            return false;
        }

        String head = repositorio.reset()
                .setMode(HARD)
                .setRef("refs/remotes/origin/master")
                .call()
                .getObjectId()
                .getName();

        if (oldHead.equals(head)) {
            log.info("Repositório de cartas de serviço em {} já está na versão mais recente: {}", caminhoLocal, head);
            return false;

        }

        log.info("Repositório de cartas de serviço em {} atualizado da versão {} para {}", caminhoLocal, oldHead, head);
        return true;
    }
}
 
Example #13
Source File: GitConfigStore.java    From vertx-config with Apache License 2.0 5 votes vote down vote up
private Future<Void> update() {
  Promise<Void> result = Promise.promise();
  vertx.executeBlocking(
    future -> {
      PullResult call;
      try {
        call = git.pull().setRemote(remote).setRemoteBranchName(branch).setCredentialsProvider(credentialProvider)
                .setTransportConfigCallback(transportConfigCallback).call();
      } catch (GitAPIException e) {
        future.fail(e);
        return;
      }
      if (call.isSuccessful()) {
        future.complete();
      } else {
        if (call.getMergeResult() != null) {
          future.fail("Unable to merge repository - Conflicts: "
            + call.getMergeResult().getCheckoutConflicts());
        } else {
          future.fail("Unable to rebase repository - Conflicts: "
            + call.getRebaseResult().getConflicts());
        }
      }
    },
    result
  );
  return result.future();
}
 
Example #14
Source File: GitConfigStore.java    From vertx-config with Apache License 2.0 5 votes vote down vote up
private Git initializeGit() throws IOException, GitAPIException {
  if (path.isDirectory()) {
    Git git = Git.open(path);
    String current = git.getRepository().getBranch();
    if (branch.equalsIgnoreCase(current)) {
      PullResult pull = git.pull().setRemote(remote).setCredentialsProvider(credentialProvider)
        .setTransportConfigCallback(transportConfigCallback).call();
      if (!pull.isSuccessful()) {
        LOGGER.warn("Unable to pull the branch + '" + branch +
          "' from the remote repository '" + remote + "'");
      }
      return git;
    } else {
      git.checkout()
        .setName(branch)
        .setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.TRACK)
        .setStartPoint(remote + "/" + branch)
        .call();
      return git;
    }
  } else {
    return Git.cloneRepository()
      .setURI(url)
      .setBranch(branch)
      .setRemote(remote)
      .setDirectory(path)
      .setCredentialsProvider(credentialProvider)
      .setTransportConfigCallback(transportConfigCallback)
      .call();
  }
}
 
Example #15
Source File: InitDBBootApplication.java    From singleton with Eclipse Public License 2.0 5 votes vote down vote up
public void  updateDBdata() throws InterruptedException {
  File file = ps.downloadDocBySsh();
ps.done(file);
logger.info("end init translate data to db--------------------------------------");
ps.gitStatus();

while (ps.getGitProp().getCheckIntervalTime() > 60000) {

	Thread.sleep(ps.getGitProp().getCheckIntervalTime());

	logger.info("----------------------beign pull status --------------------------");

	logger.info("begin pull from remote");
	PullResult pullRS = ps.gitpull();
	logger.info("end pull from remote");
	logger.info("--------------the pull status-" + pullRS.getMergeResult().getMergeStatus());

	if (pullRS.isSuccessful()
			&& !pullRS.getMergeResult().getMergeStatus().equals(MergeStatus.ALREADY_UP_TO_DATE)) {
		logger.info("remote translation files have updated!!!");
		logger.info("begin update data to DB");
		ps.done(file);
		logger.info("end updated data to DB");

	} else if (pullRS.isSuccessful()
			&& pullRS.getMergeResult().getMergeStatus().equals(MergeStatus.ALREADY_UP_TO_DATE)) {
		logger.info("remote translation file have not updated!!!");
	} else {
		logger.error("remote translation file merged error");
		file = ps.downloadDocBySsh();
		ps.done(file);

	}

}

logger.info("------------------------------end done run----------------------------");
 }
 
Example #16
Source File: GitBranchTest.java    From orion.server with Eclipse Public License 1.0 4 votes vote down vote up
@Test
public void testCreateTrackingBranch() throws Exception {
	createWorkspace(SimpleMetaStore.DEFAULT_WORKSPACE_NAME);
	IPath[] clonePaths = createTestProjects(workspaceLocation);

	for (IPath clonePath : clonePaths) {
		// clone a  repo
		JSONObject clone = clone(clonePath);
		String cloneLocation = clone.getString(ProtocolConstants.KEY_LOCATION);
		String cloneContentLocation = clone.getString(ProtocolConstants.KEY_CONTENT_LOCATION);
		String branchesLocation = clone.getString(GitConstants.KEY_BRANCH);

		// overwrite user settings, do not rebase when pulling, see bug 372489
		StoredConfig cfg = getRepositoryForContentLocation(cloneContentLocation).getConfig();
		cfg.setBoolean(ConfigConstants.CONFIG_BRANCH_SECTION, Constants.MASTER, ConfigConstants.CONFIG_KEY_REBASE, false);
		cfg.save();

		// get project/folder metadata
		WebRequest request = getGetRequest(cloneContentLocation);
		WebResponse response = webConversation.getResponse(request);
		assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
		JSONObject project = new JSONObject(response.getText());

		JSONObject gitSection = project.getJSONObject(GitConstants.KEY_GIT);
		String gitHeadUri = gitSection.getString(GitConstants.KEY_HEAD);
		String gitRemoteUri = gitSection.optString(GitConstants.KEY_REMOTE);

		// create local branch tracking origin/master
		final String BRANCH_NAME = "a";
		final String REMOTE_BRANCH = Constants.DEFAULT_REMOTE_NAME + "/" + Constants.MASTER;

		branch(branchesLocation, BRANCH_NAME, REMOTE_BRANCH);

		// modify, add, commit
		JSONObject testTxt = getChild(project, "test.txt");
		modifyFile(testTxt, "some change");
		addFile(testTxt);
		request = GitCommitTest.getPostGitCommitRequest(gitHeadUri, "commit1", false);
		response = webConversation.getResponse(request);
		assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());

		// push
		ServerStatus pushStatus = push(gitRemoteUri, 1, 0, Constants.MASTER, Constants.HEAD, false);
		assertEquals(true, pushStatus.isOK());

		// TODO: replace with RESTful API for git pull when available
		// try to pull - up to date status is expected
		Git git = Git.wrap(getRepositoryForContentLocation(cloneContentLocation));
		PullResult pullResults = git.pull().call();
		assertEquals(Constants.DEFAULT_REMOTE_NAME, pullResults.getFetchedFrom());
		assertEquals(MergeStatus.ALREADY_UP_TO_DATE, pullResults.getMergeResult().getMergeStatus());
		assertNull(pullResults.getRebaseResult());

		// checkout branch which was created a moment ago
		response = checkoutBranch(cloneLocation, BRANCH_NAME);
		assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());

		// TODO: replace with RESTful API for git pull when available
		// try to pull again - now fast forward update is expected
		pullResults = git.pull().call();
		assertEquals(Constants.DEFAULT_REMOTE_NAME, pullResults.getFetchedFrom());
		assertEquals(MergeStatus.FAST_FORWARD, pullResults.getMergeResult().getMergeStatus());
		assertNull(pullResults.getRebaseResult());
	}
}
 
Example #17
Source File: Pull.java    From wandora with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void execute(Wandora wandora, Context context) {

    try {
        Git git = getGit();
        if(git != null) {
            if(isNotEmpty(getGitRemoteUrl())) {
                PullCommand pull = git.pull();
                String user = getUsername();
                if(user == null) {
                    if(pullUI == null) {
                        pullUI = new PullUI();
                    }
                    pullUI.setUsername(getUsername());
                    pullUI.setPassword(getPassword());
                    pullUI.setRemoteUrl(getGitRemoteUrl());

                    pullUI.openInDialog();

                    if(pullUI.wasAccepted()) {
                        setUsername(pullUI.getUsername());
                        setPassword(pullUI.getPassword());
                        // setGitRemoteUrl(pullUI.getRemoteUrl());    
                        
                        // pull.setRemote(pullUI.getRemoteUrl());
                        if(isNotEmpty(getUsername())) {
                            CredentialsProvider credentialsProvider = new UsernamePasswordCredentialsProvider( getUsername(), getPassword() );
                            pull.setCredentialsProvider(credentialsProvider);
                        }
                    }
                    else {
                        return;
                    }
                }

                setDefaultLogger();
                setLogTitle("Git pull");

                log("Pulling changes from remote repository...");
                PullResult result = pull.call();

                FetchResult fetchResult = result.getFetchResult();
                MergeResult mergeResult = result.getMergeResult();
                MergeStatus mergeStatus = mergeResult.getMergeStatus();

                String fetchResultMessages = fetchResult.getMessages();
                if(isNotEmpty(fetchResultMessages)) {
                    log(fetchResult.getMessages());
                }
                log(mergeStatus.toString());

                if(mergeStatus.equals(MergeStatus.MERGED)) {
                    int a = WandoraOptionPane.showConfirmDialog(wandora, "Reload Wandora project after pull?", "Reload Wandora project after pull?", WandoraOptionPane.YES_NO_OPTION);
                    if(a == WandoraOptionPane.YES_OPTION) {
                        reloadWandoraProject();
                    }
                }
                log("Ready.");
            }
            else {
                log("Repository has no remote origin and can't be pulled. " 
                    + "Initialize repository by cloning remote repository to set the remote origin.");
            }
        }
        else {
            logAboutMissingGitRepository();
        }
    }
    catch(GitAPIException gae) {
        log(gae.toString());
    }
    catch(NoWorkTreeException nwte) {
        log(nwte.toString());
    }
    catch(Exception e) {
        log(e);
    }
    setState(WAIT);
}
 
Example #18
Source File: PullJob.java    From orion.server with Eclipse Public License 1.0 4 votes vote down vote up
private IStatus doPull(IProgressMonitor monitor) throws IOException, GitAPIException, CoreException {
	ProgressMonitor gitMonitor = new EclipseGitProgressTransformer(monitor);
	Repository db = null;
	try {
		db = FileRepositoryBuilder.create(GitUtils.getGitDir(path));
		Git git = Git.wrap(db);
		PullCommand pc = git.pull();
		pc.setProgressMonitor(gitMonitor);
		pc.setCredentialsProvider(credentials);
		pc.setTransportConfigCallback(new TransportConfigCallback() {
			@Override
			public void configure(Transport t) {
				credentials.setUri(t.getURI());
				if (t instanceof TransportHttp && cookie != null) {
					HashMap<String, String> map = new HashMap<String, String>();
					map.put(GitConstants.KEY_COOKIE, cookie.getName() + "=" + cookie.getValue());
					((TransportHttp) t).setAdditionalHeaders(map);
				}
			}
		});
		PullResult pullResult = pc.call();

		if (monitor.isCanceled()) {
			return new Status(IStatus.CANCEL, GitActivator.PI_GIT, "Cancelled");
		}

		// handle result
		if (pullResult.isSuccessful()) {
			return Status.OK_STATUS;
		}
		FetchResult fetchResult = pullResult.getFetchResult();

		IStatus fetchStatus = FetchJob.handleFetchResult(fetchResult);
		if (!fetchStatus.isOK()) {
			return fetchStatus;
		}

		MergeStatus mergeStatus = pullResult.getMergeResult().getMergeStatus();
		if (!mergeStatus.isSuccessful())
			return new Status(IStatus.ERROR, GitActivator.PI_GIT, mergeStatus.name());
	} finally {
		if (db != null) {
			db.close();
		}
	}
	return Status.OK_STATUS;
}
 
Example #19
Source File: ThemeServiceImpl.java    From halo with GNU General Public License v3.0 4 votes vote down vote up
private void pullFromGit(@NonNull ThemeProperty themeProperty) throws
    IOException, GitAPIException, URISyntaxException {
    Assert.notNull(themeProperty, "Theme property must not be null");

    // Get branch
    String branch = StringUtils.isBlank(themeProperty.getBranch()) ?
        DEFAULT_REMOTE_BRANCH : themeProperty.getBranch();

    Git git = null;

    try {
        git = GitUtils.openOrInit(Paths.get(themeProperty.getThemePath()));

        Repository repository = git.getRepository();

        RevWalk revWalk = new RevWalk(repository);

        Ref ref = repository.findRef(Constants.HEAD);

        Assert.notNull(ref, Constants.HEAD + " ref was not found!");

        RevCommit lastCommit = revWalk.parseCommit(ref.getObjectId());

        // Force to set remote name
        git.remoteRemove().setRemoteName(THEME_PROVIDER_REMOTE_NAME).call();
        RemoteConfig remoteConfig = git.remoteAdd()
            .setName(THEME_PROVIDER_REMOTE_NAME)
            .setUri(new URIish(themeProperty.getRepo()))
            .call();

        // Add all changes
        git.add()
            .addFilepattern(".")
            .call();
        // Commit the changes
        git.commit().setMessage("Commit by halo automatically").call();

        // Check out to specified branch
        if (!StringUtils.equalsIgnoreCase(branch, git.getRepository().getBranch())) {
            boolean present = git.branchList()
                .call()
                .stream()
                .map(Ref::getName)
                .anyMatch(name -> StringUtils.equalsIgnoreCase(name, branch));

            git.checkout()
                .setCreateBranch(true)
                .setForced(!present)
                .setName(branch)
                .call();
        }

        // Pull with rebasing
        PullResult pullResult = git.pull()
            .setRemote(remoteConfig.getName())
            .setRemoteBranchName(branch)
            .setRebase(true)
            .call();

        if (!pullResult.isSuccessful()) {
            log.debug("Rebase result: [{}]", pullResult.getRebaseResult());
            log.debug("Merge result: [{}]", pullResult.getMergeResult());

            throw new ThemeUpdateException("拉取失败!您与主题作者可能同时更改了同一个文件");
        }

        // updated successfully.
        ThemeProperty updatedThemeProperty = getProperty(Paths.get(themeProperty.getThemePath()));

        // Not support current halo version.
        if (StringUtils.isNotEmpty(updatedThemeProperty.getRequire()) && !VersionUtil.compareVersion(HaloConst.HALO_VERSION, updatedThemeProperty.getRequire())) {
            // reset theme version
            git.reset()
                .setMode(ResetCommand.ResetType.HARD)
                .setRef(lastCommit.getName())
                .call();
            throw new ThemeNotSupportException("新版本主题仅支持 Halo " + updatedThemeProperty.getRequire() + " 以上的版本");
        }
    } finally {
        GitUtils.closeQuietly(git);
    }

}
 
Example #20
Source File: Send2GitSchedule.java    From singleton with Eclipse Public License 2.0 4 votes vote down vote up
public PullResult gitpull() {
	return GitUtils.gitPull(new File(getGitRespPath()), gitBranch, gitPasswd, priKeyPath,
			pubKeyPath);
}
 
Example #21
Source File: ProcessService.java    From singleton with Eclipse Public License 2.0 4 votes vote down vote up
public PullResult gitpull() {
	return GitUtils.gitPull(new File(this.gitProp.getLocalFolder()));
}