• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java StatusCommand类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.eclipse.jgit.api.StatusCommand的典型用法代码示例。如果您正苦于以下问题:Java StatusCommand类的具体用法?Java StatusCommand怎么用?Java StatusCommand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



StatusCommand类属于org.eclipse.jgit.api包,在下文中一共展示了StatusCommand类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: status

import org.eclipse.jgit.api.StatusCommand; //导入依赖的package包/类
@Override
public Status status(List<String> filter) throws GitException {
  if (!isInsideWorkTree()) {
    throw new GitInvalidRepositoryException(NOT_A_GIT_REPOSITORY_ERROR);
  }
  String repositoryPath = getRepositoryPath();
  // Status can be not actual, if commit is in progress.
  if (COMMITTING_REPOSITORIES.contains(repositoryPath)) {
    throw new GitCommitInProgressException(COMMIT_IN_PROGRESS_ERROR);
  }
  // Status can be not actual, if checkout is in progress.
  if (CHECKOUT_REPOSITORIES.contains(repositoryPath)) {
    throw new GitCheckoutInProgressException(CHECKOUT_IN_PROGRESS_ERROR);
  }
  String branchName = getCurrentBranch();
  StatusCommand statusCommand = getGit().status();
  if (filter != null) {
    filter.forEach(statusCommand::addPath);
  }
  return new JGitStatusImpl(branchName, statusCommand);
}
 
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:JGitConnection.java


示例2: JGitStatusImpl

import org.eclipse.jgit.api.StatusCommand; //导入依赖的package包/类
/**
 * @param branchName current repository branch name
 * @param statusCommand Jgit status command
 * @throws GitException when any error occurs
 */
public JGitStatusImpl(String branchName, StatusCommand statusCommand) throws GitException {
  this.branchName = branchName;

  org.eclipse.jgit.api.Status gitStatus;
  try {
    gitStatus = statusCommand.call();
  } catch (GitAPIException exception) {
    throw new GitException(exception.getMessage(), exception);
  }

  clean = gitStatus.isClean();
  added = new ArrayList<>(gitStatus.getAdded());
  changed = new ArrayList<>(gitStatus.getChanged());
  removed = new ArrayList<>(gitStatus.getRemoved());
  missing = new ArrayList<>(gitStatus.getMissing());
  modified = new ArrayList<>(gitStatus.getModified());
  untracked = new ArrayList<>(gitStatus.getUntracked());
  untrackedFolders = new ArrayList<>(gitStatus.getUntrackedFolders());
  conflicting = new ArrayList<>(gitStatus.getConflicting());
}
 
开发者ID:eclipse,项目名称:che,代码行数:26,代码来源:JGitStatusImpl.java


示例3: shouldPullForcepullNotClean

import org.eclipse.jgit.api.StatusCommand; //导入依赖的package包/类
@Test
public void shouldPullForcepullNotClean() throws Exception {
	Git git = mock(Git.class);
	StatusCommand statusCommand = mock(StatusCommand.class);
	Status status = mock(Status.class);
	Repository repository = mock(Repository.class);
	StoredConfig storedConfig = mock(StoredConfig.class);

	when(git.status()).thenReturn(statusCommand);
	when(git.getRepository()).thenReturn(repository);
	when(repository.getConfig()).thenReturn(storedConfig);
	when(storedConfig.getString("remote", "origin", "url")).thenReturn("http://example/git");
	when(statusCommand.call()).thenReturn(status);
	when(status.isClean()).thenReturn(false);

	JGitEnvironmentRepository repo = new JGitEnvironmentRepository(this.environment);
	repo.setForcePull(true);

	boolean shouldPull = repo.shouldPull(git);

	assertThat("shouldPull was false", shouldPull, is(true));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-config,代码行数:23,代码来源:JGitEnvironmentRepositoryTests.java


示例4: shouldPullNotClean

import org.eclipse.jgit.api.StatusCommand; //导入依赖的package包/类
@Test
public void shouldPullNotClean() throws Exception {
	Git git = mock(Git.class);
	StatusCommand statusCommand = mock(StatusCommand.class);
	Status status = mock(Status.class);
	Repository repository = mock(Repository.class);
	StoredConfig storedConfig = mock(StoredConfig.class);

	when(git.status()).thenReturn(statusCommand);
	when(git.getRepository()).thenReturn(repository);
	when(repository.getConfig()).thenReturn(storedConfig);
	when(storedConfig.getString("remote", "origin", "url")).thenReturn("http://example/git");
	when(statusCommand.call()).thenReturn(status);
	when(status.isClean()).thenReturn(false);

	JGitEnvironmentRepository repo = new JGitEnvironmentRepository(this.environment);

	boolean shouldPull = repo.shouldPull(git);

	assertThat("shouldPull was true", shouldPull, is(false));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-config,代码行数:22,代码来源:JGitEnvironmentRepositoryTests.java


示例5: shouldPullClean

import org.eclipse.jgit.api.StatusCommand; //导入依赖的package包/类
@Test
public void shouldPullClean() throws Exception {
	Git git = mock(Git.class);
	StatusCommand statusCommand = mock(StatusCommand.class);
	Status status = mock(Status.class);
	Repository repository = mock(Repository.class);
	StoredConfig storedConfig = mock(StoredConfig.class);

	when(git.status()).thenReturn(statusCommand);
	when(git.getRepository()).thenReturn(repository);
	when(repository.getConfig()).thenReturn(storedConfig);
	when(storedConfig.getString("remote", "origin", "url")).thenReturn("http://example/git");
	when(statusCommand.call()).thenReturn(status);
	when(status.isClean()).thenReturn(true);

	JGitEnvironmentRepository repo = new JGitEnvironmentRepository(this.environment);

	boolean shouldPull = repo.shouldPull(git);

	assertThat("shouldPull was false", shouldPull, is(true));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-config,代码行数:22,代码来源:JGitEnvironmentRepositoryTests.java


示例6: getStatus

import org.eclipse.jgit.api.StatusCommand; //导入依赖的package包/类
public Status getStatus(String path) throws Exception {
    fetch();
    StatusCommand sc = git.status();
    if (path != null)
        sc.addPath(path);
    return sc.call();
}
 
开发者ID:CenturyLinkCloud,项目名称:mdw,代码行数:8,代码来源:VersionControlGit.java


示例7: isClean

import org.eclipse.jgit.api.StatusCommand; //导入依赖的package包/类
private boolean isClean(Git git) {
	StatusCommand status = git.status();
	try {
		return status.call().isClean();
	}
	catch (Exception e) {
		String message = "Could not execute status command on local repository. Cause: ("
				+ e.getClass().getSimpleName() + ") " + e.getMessage();
		warn(message, e);
		return false;
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-config,代码行数:13,代码来源:JGitEnvironmentRepository.java


示例8: testInit_gitStatusApiException

import org.eclipse.jgit.api.StatusCommand; //导入依赖的package包/类
@Test
public void testInit_gitStatusApiException()
        throws RevisionGeneratorException,
        GitAPIException, 
        IOException {

    String branch = "master";
    String hash = UUID.randomUUID().toString().replaceAll("-", "")+UUID.randomUUID().toString().replaceAll("-", "").substring(0,8);
    String abbreviatedHash = hash.substring(0, 5);
    AbbreviatedObjectId abbreviatedObjectId = AbbreviatedObjectId.fromString(abbreviatedHash);
    int commitTime = (int) (System.currentTimeMillis()/1000);
    
    RevCommit headCommit = createRevCommit(hash, commitTime);
    
    
    Repository repo = mock(Repository.class);
    Ref headRef = mock(Ref.class);
    ObjectId headObjectId = mock(ObjectId.class);
    LogCommand logCmd = mock(LogCommand.class);
    StatusCommand statusCmd = mock(StatusCommand.class);
    
    GitAPIException exception = new NoHeadException("Dummy Git API Exception");

    when(git.getRepository()).thenReturn(repo);
    when(repo.isBare()).thenReturn(Boolean.FALSE);
    when(repo.getBranch()).thenReturn(branch);
    when(repo.getRef(eq("HEAD"))).thenReturn(headRef);
    when(headRef.getObjectId()).thenReturn(headObjectId);
    when(headObjectId.abbreviate(eq(5))).thenReturn(abbreviatedObjectId);
    when(git.log()).thenReturn(logCmd);
    when(logCmd.setMaxCount(1)).thenReturn(logCmd);
    when(logCmd.call()).thenReturn(Arrays.asList(headCommit));
    when(git.status()).thenReturn(statusCmd);
    when(statusCmd.call()).thenThrow(exception);
    
    exceptions.expect(RevisionGeneratorException.class);
    exceptions.expectMessage("Issue getting Git Status");
    exceptions.expectCause(IsInstanceOf.any(GitAPIException.class));

    try {
        item.init(git, logger);
    } finally {
        verify(git).getRepository();
        verify(git).log();
        verify(repo).isBare();
        verify(repo).getRef(eq("HEAD"));
        verify(repo).getBranch();
        verify(headRef, times(2)).getObjectId();
        verify(headObjectId).abbreviate(eq(5));
        verify(logCmd).setMaxCount(eq(1));
        verify(logCmd).call();
        verify(git).status();
        verify(statusCmd).call();
        verifyNoMoreInteractions(git);
        verifyNoMoreInteractions(repo);
        verifyNoMoreInteractions(headRef);
        verifyNoMoreInteractions(headObjectId);
        verifyNoMoreInteractions(logCmd);
        verifyNoMoreInteractions(statusCmd);
        verifyZeroInteractions(logger);
    }
}
 
开发者ID:IG-Group,项目名称:cdversion-maven-extension,代码行数:63,代码来源:GitRevisionGeneratorTest.java


示例9: doInBackground

import org.eclipse.jgit.api.StatusCommand; //导入依赖的package包/类
@Override
protected String doInBackground(GitCommand... commands) {
    Integer nbChanges = null;
    for (GitCommand command : commands) {
        Log.d("doInBackground", "Executing the command <" + command.toString() + ">");
        try {
            if (command instanceof StatusCommand) {
                // in case we have changes, we want to keep track of it
                org.eclipse.jgit.api.Status status = ((StatusCommand) command).call();
                nbChanges = status.getChanged().size() + status.getMissing().size();
            } else if (command instanceof CommitCommand) {
                // the previous status will eventually be used to avoid a commit
                if (nbChanges == null || nbChanges > 0)
                    command.call();
            }else if (command instanceof PushCommand) {
                for (final PushResult result : ((PushCommand) command).call()) {
                    // Code imported (modified) from Gerrit PushOp, license Apache v2
                    for (final RemoteRefUpdate rru : result.getRemoteUpdates()) {
                        switch (rru.getStatus()) {
                            case REJECTED_NONFASTFORWARD:
                                return activity.getString(R.string.git_push_nff_error);
                            case REJECTED_NODELETE:
                            case REJECTED_REMOTE_CHANGED:
                            case NON_EXISTING:
                            case NOT_ATTEMPTED:
                                return activity.getString(R.string.git_push_generic_error) + rru.getStatus().name();
                            case REJECTED_OTHER_REASON:
                                if ("non-fast-forward".equals(rru.getMessage())) {
                                    return activity.getString(R.string.git_push_other_error);
                                } else {
                                    return activity.getString(R.string.git_push_generic_error) + rru.getMessage();
                                }
                            default:
                                break;
                        }
                    }
                }
            } else {
                command.call();
            }

        } catch (Exception e) {
            e.printStackTrace();
            return e.getMessage() + "\nCaused by:\n" + e.getCause();
        }
    }
    return "";
}
 
开发者ID:zeapo,项目名称:Android-Password-Store,代码行数:49,代码来源:GitAsyncTask.java



注:本文中的org.eclipse.jgit.api.StatusCommand类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java LogWriter类代码示例发布时间:2022-05-22
下一篇:
Java EventType类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap