Java 类org.eclipse.jgit.api.errors.WrongRepositoryStateException 实例源码

项目:PhET    文件:PullAll.java   
private static void visit( File directory ) throws IOException, RefNotFoundException, DetachedHeadException, WrongRepositoryStateException, InvalidRemoteException, InvalidConfigurationException, CanceledException {
    for ( final File child : directory.listFiles() ) {
        if ( child.isDirectory() ) {
            visit( child );
        }
        final String name = child.getName();
        if ( name.equals( ".git" ) ) {

            Thread t = new Thread( new Runnable() {
                public void run() {
                    try {
                        Git git = Git.open( child.getParentFile() );
                        PullResult pullResult = git.pull().call();
                        System.out.println( "pulled on " + child.getParentFile().getName() + ", pullResult = " + pullResult.isSuccessful() + ", " + pullResult.getFetchedFrom() + ", fetch messages: " + pullResult.getFetchResult().getMessages() );
                    }
                    catch ( Exception e ) {
                        e.printStackTrace();
                    }
                }
            } );
            t.start();

        }
    }
}
项目:gitlab-plugin    文件:MergeRequestHookTriggerHandlerImplTest.java   
private OneShotEvent doHandle(MergeRequestHookTriggerHandler mergeRequestHookTriggerHandler,
        MergeRequestObjectAttributesBuilder objectAttributes) throws GitAPIException, IOException, NoHeadException,
        NoMessageException, UnmergedPathsException, ConcurrentRefUpdateException, WrongRepositoryStateException,
        AmbiguousObjectException, IncorrectObjectTypeException, MissingObjectException, InterruptedException {
    Git.init().setDirectory(tmp.getRoot()).call();
       tmp.newFile("test");
       Git git = Git.open(tmp.getRoot());
       git.add().addFilepattern("test");
       RevCommit commit = git.commit().setMessage("test").call();
       ObjectId head = git.getRepository().resolve(Constants.HEAD);
       String repositoryUrl = tmp.getRoot().toURI().toString();

       final OneShotEvent buildTriggered = new OneShotEvent();
       FreeStyleProject project = jenkins.createFreeStyleProject();
       project.setScm(new GitSCM(repositoryUrl));
       project.getBuildersList().add(new TestBuilder() {
           @Override
           public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
               buildTriggered.signal();
               return true;
           }
       });
       project.setQuietPeriod(0);
    mergeRequestHookTriggerHandler.handle(project, mergeRequestHook()
               .withObjectAttributes(objectAttributes
                    .withTargetBranch("refs/heads/" + git.nameRev().add(head).call().get(head))
                    .withLastCommit(commit().withAuthor(user().withName("test").build()).withId(commit.getName()).build())
                   .build())
               .withProject(project()
                   .withWebUrl("https://gitlab.org/test.git")
                   .build()
               )
               .build(), true, BranchFilterFactory.newBranchFilter(branchFilterConfig().build(BranchFilterType.All)),
           newMergeRequestLabelFilter(null));

       buildTriggered.block(10000);
       return buildTriggered;
}
项目:ivy-pdi-git-steps    文件:PullGitCommand.java   
public Git call(final GitOperationsStep gitOperationsStep, Git git,
    CredentialsProvider cp, String gitRepoUrl, File gitRepoFolder)
    throws IllegalArgumentException, IOException,
    WrongRepositoryStateException, InvalidConfigurationException,
    DetachedHeadException, InvalidRemoteException, CanceledException,
    RefNotFoundException, NoHeadException, TransportException,
    GitAPIException {
  git.pull().setCredentialsProvider(cp).setRebase(rebase).call();
  return git;
}
项目:ivy-pdi-git-steps    文件:CommitGitCommand.java   
public Git call(final GitOperationsStep gitOperationsStep, Git git,
    CredentialsProvider cp, String gitRepoUrl, File gitRepoFolder)
    throws IllegalArgumentException, IOException, NoHeadException,
    NoMessageException, UnmergedPathsException,
    ConcurrentRefUpdateException, WrongRepositoryStateException,
    GitAPIException {
  CommitCommand cc = git
      .commit()
      .setAuthor(
          gitOperationsStep
              .environmentSubstitute(this.authorName == null ? ""
                  : this.authorName),
          gitOperationsStep
              .environmentSubstitute(this.authorEmail == null ? ""
                  : this.authorEmail))
      .setCommitter(
          gitOperationsStep
              .environmentSubstitute(this.committerName == null ? ""
                  : this.committerName),
          gitOperationsStep
              .environmentSubstitute(this.committerEmail == null ? ""
                  : this.committerName));

  if (!Const.isEmpty(this.commitMessage)) {
    cc = cc.setMessage(gitOperationsStep
        .environmentSubstitute(this.commitMessage));
  }
  cc.setAll(all).setInsertChangeId(insertChangeId).setAmend(amend).call();
  return git;
}
项目:gradle-gitsemver    文件:TagBasedVersionFactoryTest.java   
@Before
public void createVersionFactory() throws IOException, NoHeadException,
        NoMessageException, UnmergedPathsException,
        ConcurrentRefUpdateException, WrongRepositoryStateException,
        GitAPIException {
    repo = createRepository();
    git = initializeGitFlow(repo);
    versionFactory = new TagBasedVersionFactory();
}
项目:gradle-gitsemver    文件:TagBasedVersionFactoryTest.java   
@Test
public void testCommitCount() throws NoHeadException, NoMessageException,
        UnmergedPathsException, ConcurrentRefUpdateException,
        WrongRepositoryStateException, GitAPIException,
        NoWorkTreeException, IOException {
    tag("v0.1.1-rc");
    makeCommit();
    makeCommit();
    RevCommit head = makeCommit();
    validateUnstable("0.1.1-rc", 3, head, Dirty.NO, DOT);
}
项目:SGit    文件:CommitChangesTask.java   
public static void commit(Repo repo, boolean stageAll, boolean isAmend,
        String msg, String authorName, String authorEmail) throws Exception, NoHeadException, NoMessageException,
        UnmergedPathsException, ConcurrentRefUpdateException,
        WrongRepositoryStateException, GitAPIException, StopTaskException {
    Context context = SGitApplication.getContext();
    StoredConfig config = repo.getGit().getRepository().getConfig();
    String committerEmail = config.getString("user", null, "email");
    String committerName = config.getString("user", null, "name");

    if (committerName == null || committerName.equals("")) {
        committerName = Profile.getUsername(context);
    }
    if (committerEmail == null || committerEmail.equals("")) {
        committerEmail = Profile.getEmail(context);
    }
    if (committerName.isEmpty() || committerEmail.isEmpty()) {
        throw new Exception("Please set your name and email");
    }
    if (msg.isEmpty()) {
        throw new Exception("Please include a commit message");
    }
    CommitCommand cc = repo.getGit().commit()
            .setCommitter(committerName, committerEmail).setAll(stageAll)
            .setAmend(isAmend).setMessage(msg);
    if (authorName != null && authorEmail != null) {
        cc.setAuthor(authorName, authorEmail);
    }
    cc.call();
    repo.updateLatestCommitInfo();
}
项目:cwlviewer    文件:WorkflowControllerTest.java   
/**
 * Displaying workflows
 */
@Test
public void directWorkflowURL() throws Exception {

    Workflow mockWorkflow = Mockito.mock(Workflow.class);
    QueuedWorkflow mockQueuedWorkflow = Mockito.mock(QueuedWorkflow.class);
    when(mockQueuedWorkflow.getWorkflowList()).thenReturn(null);

    // Mock service
    WorkflowService mockWorkflowService = Mockito.mock(WorkflowService.class);
    when(mockWorkflowService.getWorkflow(Matchers.<GitDetails>anyObject()))
            .thenReturn(mockWorkflow)
            .thenReturn(null);
    when(mockWorkflowService.createQueuedWorkflow(anyObject()))
            .thenReturn(mockQueuedWorkflow)
            .thenThrow(new WorkflowNotFoundException())
            .thenThrow(new WrongRepositoryStateException("Some Error"))
            .thenThrow(new TransportException("No SSH Key"))
            .thenThrow(new IOException());
    List<WorkflowOverview> listOfTwoOverviews = new ArrayList<>();
    listOfTwoOverviews.add(new WorkflowOverview("/workflow1.cwl", "label", "doc"));
    listOfTwoOverviews.add(new WorkflowOverview("/workflow2.cwl", "label2", "doc2"));
    when(mockWorkflowService.getWorkflowsFromDirectory(anyObject()))
            .thenReturn(listOfTwoOverviews)
            .thenReturn(Collections.singletonList(new WorkflowOverview("/workflow1.cwl", "label", "doc")));

    // Mock controller/MVC
    WorkflowController workflowController = new WorkflowController(
            Mockito.mock(WorkflowFormValidator.class),
            mockWorkflowService,
            Mockito.mock(GraphVizService.class));
    MockMvc mockMvc = MockMvcBuilders
            .standaloneSetup(workflowController)
            .build();

    // Workflow already exists in the database
    mockMvc.perform(get("/workflows/github.com/owner/reponame/tree/branch/path/within/workflow.cwl"))
            .andExpect(status().isOk())
            .andExpect(view().name("workflow"))
            .andExpect(model().attribute("workflow", is(mockWorkflow)));

    // Workflow needs to be created, loading page
    mockMvc.perform(get("/workflows/github.com/owner/reponame/tree/branch/path/within/workflow.cwl"))
            .andExpect(status().isOk())
            .andExpect(view().name("loading"))
            .andExpect(model().attribute("queued", is(mockQueuedWorkflow)));

    // Directory URL, select between
    mockMvc.perform(get("/workflows/github.com/owner/reponame/tree/branch/path/within"))
            .andExpect(status().isOk())
            .andExpect(view().name("selectworkflow"))
            .andExpect(model().attributeExists("gitDetails"))
            .andExpect(model().attributeExists("workflowOverviews"));

    // Directory URL with only one workflow redirects
    mockMvc.perform(get("/workflows/github.com/owner/reponame/tree/branch/path/within"))
            .andExpect(status().isFound())
            .andExpect(redirectedUrl("/workflows/github.com/owner/reponame/blob/branch/path/within/workflow1.cwl"));

    // Workflow not found
    mockMvc.perform(get("/workflows/github.com/owner/reponame/tree/branch/path/within/nonexistant.cwl"))
            .andExpect(status().isFound())
            .andExpect(MockMvcResultMatchers.flash().attributeExists("errors"));

    // Git API error
    mockMvc.perform(get("/workflows/github.com/owner/reponame/tree/branch/path/within/cantbecloned.cwl"))
            .andExpect(status().isFound())
            .andExpect(MockMvcResultMatchers.flash().attributeExists("errors"));

    // Submodules with SSH Url
    mockMvc.perform(get("/workflows/github.com/owner/reponame/tree/branch/path/within/submodulewithssh.cwl"))
            .andExpect(status().isFound())
            .andExpect(MockMvcResultMatchers.flash().attributeExists("errors"));

    // Unexpected error
    mockMvc.perform(get("/workflows/github.com/owner/reponame/tree/branch/path/within/badworkflow.cwl"))
            .andExpect(status().isFound())
            .andExpect(MockMvcResultMatchers.flash().attributeExists("errors"));
}
项目:PhET    文件:PullAll.java   
public static void main( String[] args ) throws IOException, RefNotFoundException, DetachedHeadException, WrongRepositoryStateException, InvalidRemoteException, InvalidConfigurationException, CanceledException {
    visit( new File( "C:\\workingcopy\\phet-little-gits" ) );
}
项目:gradle-gitsemver    文件:TagBasedVersionFactoryTest.java   
private RevCommit makeCommit() throws NoHeadException, NoMessageException,
        UnmergedPathsException, ConcurrentRefUpdateException,
        WrongRepositoryStateException, GitAPIException {
    return git.commit().setCommitter(COMMITTER).setMessage("some commit").call();
}