org.apache.maven.plugin.PluginParameterExpressionEvaluator#org.eclipse.jgit.api.errors.GitAPIException源码实例Demo

下面列出了org.apache.maven.plugin.PluginParameterExpressionEvaluator#org.eclipse.jgit.api.errors.GitAPIException 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@Test
public void pushFailsOnInvalidFiles() throws IOException, GitAPIException, InterruptedException {
    MockSnapshotServer server = new MockSnapshotServer(3869, getResource("/pushFailsOnInvalidFiles").toFile());
    server.start();
    server.setState(states.get("pushFailsOnInvalidFiles").get("state"));
    GitBridgeApp wlgb = new GitBridgeApp(new String[] {
        makeConfigFile(33869, 3869)
    });
    wlgb.run();
    File testprojDir = gitClone("testproj", 33869, dir);
    assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/pushFailsOnInvalidFiles/state/testproj"), testprojDir.toPath()));
    runtime.exec("touch push.tex", null, testprojDir).waitFor();
    gitAdd(testprojDir);
    gitCommit(testprojDir, "push");
    Process push = gitPush(testprojDir, 1);
    wlgb.stop();
    List<String> actual = Util.linesFromStream(push.getErrorStream(), 2, "[K");
    assertEquals(EXPECTED_OUT_PUSH_INVALID_FILES, actual);
}
 
源代码2 项目: mcg-helper   文件: JGitUtil.java
public static boolean cloneRepository(String remoteUrl, String branch, String projectPath, String user, String pwd) throws InvalidRemoteException, TransportException, GitAPIException {
   	File projectDir = new File(projectPath);

       UsernamePasswordCredentialsProvider provider = new UsernamePasswordCredentialsProvider(user, pwd);
       try (Git git = Git.cloneRepository()
               .setURI(remoteUrl)
               .setBranch(branch)
               .setDirectory(projectDir)
               .setCredentialsProvider(provider)
               .setProgressMonitor(new CloneProgressMonitor())
               .call()) {
       	
       }
       
       return true;
}
 
@Test
public void singleChanged_buildUpstream_modeChanged() throws GitAPIException, IOException {
    MavenProject changedModuleMock = addModuleMock(AID_MODULE_B, true);
    MavenProject unchangedModuleMock = addModuleMock("unchanged-module", false);
    MavenProject dependsOnBothModuleMock = addModuleMock("changed-and-unchanged-dependent", false);

    when(mavenExecutionRequestMock.getMakeBehavior()).thenReturn(MavenExecutionRequest.REACTOR_MAKE_UPSTREAM);

    setUpAndDownstreamsForBuildUpstreamModeTests(changedModuleMock, unchangedModuleMock, dependsOnBothModuleMock);

    addGibProperty(Property.buildUpstreamMode, "changed");

    underTest.act();

    verify(mavenSessionMock).setProjects(Arrays.asList(moduleA, changedModuleMock, dependsOnBothModuleMock));

    assertProjectPropertiesEqual(moduleA, Collections.emptyMap());
    assertProjectPropertiesEqual(changedModuleMock, Collections.emptyMap());
    assertProjectPropertiesEqual(unchangedModuleMock, Collections.emptyMap());
    assertProjectPropertiesEqual(dependsOnBothModuleMock, Collections.emptyMap());
}
 
源代码4 项目: netbeans   文件: SubmoduleStatusCommand.java
@Override
protected void run () throws GitException {
    Repository repository = getRepository();
    File workTree = repository.getWorkTree();
    org.eclipse.jgit.api.SubmoduleStatusCommand cmd = new Git(repository).submoduleStatus();
    for (String path : Utils.getRelativePaths(workTree, roots)) {
        cmd.addPath(path);
    }
    try {
        Map<String, SubmoduleStatus> result = cmd.call();
        GitClassFactory fac = getClassFactory();
        for (Map.Entry<String, SubmoduleStatus> e : result.entrySet()) {
            File root = new File(workTree, e.getKey());
            statuses.put(root, fac.createSubmoduleStatus(e.getValue(), root));
        }
    } catch (GitAPIException | JGitInternalException ex) {
        throw new GitException(ex);
    }
}
 
源代码5 项目: vertx-config   文件: GitConfigStoreTest.java
@Test
public void testWith2FileSetsAndNoIntersection(TestContext tc) throws GitAPIException, IOException {
  Async async = tc.async();
  add(git, root, new File("src/test/resources/files/regular.json"), "file");
  add(git, root, new File("src/test/resources/files/a.json"), "dir");
  push(git);

  retriever = ConfigRetriever.create(vertx, new ConfigRetrieverOptions().addStore(new
      ConfigStoreOptions().setType("git").setConfig(new JsonObject()
      .put("url", bareRoot.getAbsolutePath())
      .put("path", "target/junk/work")
      .put("filesets", new JsonArray()
          .add(new JsonObject().put("pattern", "file/reg*.json"))
          .add(new JsonObject().put("pattern", "dir/a.*son"))
      ))));

  retriever.getConfig(ar -> {
    assertThat(ar.result().getString("key")).isEqualTo("value");
    assertThat(ar.result().getString("a.name")).isEqualTo("A");
    async.complete();
  });

}
 
public LocalRepoMock(File baseFolder, TestServerType remoteRepoServerType) throws IOException, URISyntaxException, GitAPIException {
    this.baseFolder = new File(baseFolder.getAbsolutePath(), "tmp/repo/");
    new UnZipper().act(templateProjectZip, this.baseFolder);

    remoteRepo = remoteRepoServerType != null ? new RemoteRepoMock(baseFolder, remoteRepoServerType) : null;
    git = new Git(new FileRepository(new File(this.baseFolder, ".git")));

    if (remoteRepoServerType != null) {
        try {
            configureRemote(git, remoteRepo.repoUri.toString());
        } catch (IOException | URISyntaxException | GitAPIException | RuntimeException e) {
            close();
            throw e;
        }
    }
}
 
源代码7 项目: nano-framework   文件: GitPull.java
public GitPull quickPull(String... args) {
    if (!ArrayUtils.isEmpty(args)) {
        for (final String arg : args) {
            if (StringUtils.equals("stop", StringUtils.lowerCase(arg))) {
                return this;
            }
        }
    }

    if (enabled) {
        try {
            return dir().pull().copy().clean();
        } catch (final IOException | GitAPIException e) {
            throw new org.nanoframework.server.exception.GitAPIException(e.getMessage(), e);
        }
    }

    return this;
}
 
@Test
public void pushFailsOnInvalidProject() throws IOException, GitAPIException, InterruptedException {
    MockSnapshotServer server = new MockSnapshotServer(3870, getResource("/pushFailsOnInvalidProject").toFile());
    server.start();
    server.setState(states.get("pushFailsOnInvalidProject").get("state"));
    GitBridgeApp wlgb = new GitBridgeApp(new String[] {
        makeConfigFile(33870, 3870)
    });
    wlgb.run();
    File testprojDir = gitClone("testproj", 33870, dir);
    assertTrue(FileUtil.gitDirectoriesAreEqual(getResource("/pushFailsOnInvalidProject/state/testproj"), testprojDir.toPath()));
    runtime.exec("touch push.tex", null, testprojDir).waitFor();
    gitAdd(testprojDir);
    gitCommit(testprojDir, "push");
    Process push = gitPush(testprojDir, 1);
    wlgb.stop();
    List<String> actual = Util.linesFromStream(push.getErrorStream(), 2, "[K");
    assertEquals(EXPECTED_OUT_PUSH_INVALID_PROJECT, actual);
}
 
源代码9 项目: proctor   文件: GitProctorCore.java
@Nullable
private Set<String> parseStagedTestNames() {
    try {
        final Status status = git.status().call();
        return Stream.of(
                status.getAdded(),
                status.getChanged(),
                status.getRemoved())
                .flatMap(Set::stream)
                .distinct()
                .map(s -> parseTestName(testDefinitionsDirectory, s))
                .filter(Objects::nonNull)
                .collect(Collectors.toSet());
    } catch (final GitAPIException | NoWorkTreeException e) {
        LOGGER.warn("Failed to call git status", e);
        return null;
    }
}
 
源代码10 项目: WebIDE-Backend   文件: SquashActionHandler.java
@Override
public RebaseResponse process(Repository repository, String message) throws GitAPIException, IOException {

    try (Git git = Git.wrap(repository)) {
        git.commit()
                .setMessage(stripCommentLines(message))
                .setAmend(true).setNoVerify(true).call();

        getRebaseFile(repository, MESSAGE_SQUASH).delete();
        getRebaseFile(repository, MESSAGE_FIXUP).delete();

        createFile(repository, MESSAGE, message);

        RebaseResult result = git.rebase()
                .setOperation(RebaseCommand.Operation.SKIP)
                .runInteractively(handler)
                .call();

        return new RebaseResponse(result);
    }
}
 
源代码11 项目: jphp   文件: WrapGit.java
@Signature
public Memory resolveCommit(String revstr) throws IOException, GitAPIException {
    ObjectId objectId = getWrappedObject().getRepository().resolve(revstr);

    if (objectId == null) {
        return Memory.NULL;
    }

    LogCommand command = getWrappedObject()
            .log()
            .add(objectId)
            .setMaxCount(1);

    Iterable<RevCommit> call = command.call();

    for (RevCommit revCommit : call) {
        return GitUtils.valueOf(revCommit);
    }

    return Memory.NULL;
}
 
源代码12 项目: zeppelin   文件: GitHubNotebookRepo.java
private void pullFromRemoteStream() {
  try {
    LOG.debug("Pulling latest changes from remote stream");
    PullCommand pullCommand = git.pull();
    pullCommand.setCredentialsProvider(
      new UsernamePasswordCredentialsProvider(
        zeppelinConfiguration.getZeppelinNotebookGitUsername(),
        zeppelinConfiguration.getZeppelinNotebookGitAccessToken()
      )
    );

    pullCommand.call();

  } catch (GitAPIException e) {
    LOG.error("Error when pulling latest changes from remote repository", e);
  }
}
 
源代码13 项目: studio   文件: GitContentRepository.java
@Override
public void resetStagingRepository(String siteId) throws ServiceLayerException {
    Repository repo = helper.getRepository(siteId, PUBLISHED);
    String stagingName = servicesConfig.getStagingEnvironment(siteId);
    String liveName = servicesConfig.getLiveEnvironment(siteId);
    synchronized (repo) {
        try (Git git = new Git(repo)) {
            logger.debug("Checkout live first becuase it is not allowed to delete checkedout branch");
            git.checkout().setName(liveName).call();
            logger.debug("Delete staging branch in order to reset it for site: " + siteId);
            git.branchDelete().setBranchNames(stagingName).setForce(true).call();

            logger.debug("Create new branch for staging with live HEAD as starting point");
            git.branchCreate()
                    .setName(stagingName)
                    .setStartPoint(liveName)
                    .call();
        } catch (GitAPIException e) {
            logger.error("Error while reseting staging environment for site: " + siteId);
            throw new ServiceLayerException(e);
        }
    }
}
 
源代码14 项目: gocd   文件: ConfigRepository.java
String getMergedConfig(String branchName, RevCommit newCommit) throws GitAPIException, IOException {
    MergeResult result = null;
    try {
        checkout(branchName);
        result = git.merge().include(newCommit).call();
    } catch (GitAPIException e) {
        LOGGER.info("[CONFIG_MERGE] Merging commit {} by user {} to branch {} at revision {} failed", newCommit.getId().getName(), newCommit.getAuthorIdent().getName(), branchName, getCurrentRevCommit().getId().getName());
        throw e;
    }
    if (!result.getMergeStatus().isSuccessful()) {
        LOGGER.info("[CONFIG_MERGE] Merging commit {} by user {} to branch {} at revision {} failed as config file has changed", newCommit.getId().getName(), newCommit.getAuthorIdent().getName(), branchName,
                getCurrentRevCommit().getId().getName());
        throw new ConfigFileHasChangedException();
    }
    LOGGER.info("[CONFIG_MERGE] Successfully merged commit {} by user {} to branch {}. Merge commit revision is {}", newCommit.getId().getName(), newCommit.getAuthorIdent().getName(), branchName, getCurrentRevCommit().getId().getName());
    return FileUtils.readFileToString(new File(workingDir, CRUISE_CONFIG_XML), UTF_8);
}
 
源代码15 项目: super-cloudops   文件: UploadUtilTests.java
@Test
public void uploadTest() throws GitAPIException {
    Netty4ClientHttpRequestFactory factory = new Netty4ClientHttpRequestFactory();
    //factory.setConnectTimeout(10_000);
    //factory.setReadTimeout(60_000);
    //factory.setMaxResponseSize(1024 * 1024 * 10);
    RestTemplate restTemplate = new RestTemplate(factory);

    FileSystemResource resource = new FileSystemResource(new File("/Users/vjay/Downloads/logo.png"));
    MultiValueMap<String, Object> param = new LinkedMultiValueMap<>();
    param.add("deviceId", "123424");
    param.add("file", resource);
    String recv = restTemplate.postForObject(uploadUrl, param, String.class);
    System.out.println(recv);

    /*MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
    map.add("id",id);
    HttpHeaders header = new HttpHeaders();
    // 需求需要传参为form-data格式
    header.setContentType(MediaType.MULTIPART_FORM_DATA);
    HttpEntity<MultiValueMap<String, String>> httpEntity = new HttpEntity<>(map, header);*/

}
 
源代码16 项目: git-merge-repos   文件: RepoMerger.java
public List<MergedRef> run() throws IOException, GitAPIException {
	fetch();
	List<MergedRef> mergedBranches = mergeBranches();
	List<MergedRef> mergedTags = mergeTags();
	List<MergedRef> mergedRefs = new ArrayList<>();
	mergedRefs.addAll(mergedBranches);
	mergedRefs.addAll(mergedTags);
	deleteOriginalRefs();
	resetToBranch();
	return mergedRefs;
}
 
@Test
public void testStableIsDirty() throws NoFilepatternException, IOException,
        GitAPIException {
    tag("0.1.0");
    dirtyRepo();
    Assert.assertEquals(
            "0.1.0+dirty",
            versionFactory.createVersion(repo, null).toString());
}
 
源代码18 项目: git-client-plugin   文件: JGitAPIImpl.java
/** {@inheritDoc} */
@Override
public Map<String, ObjectId> getRemoteReferences(String url, String pattern, boolean headsOnly, boolean tagsOnly)
        throws GitException, InterruptedException {
    Map<String, ObjectId> references = new HashMap<>();
    String regexPattern = null;
    if (pattern != null) {
        regexPattern = createRefRegexFromGlob(pattern);
    }
    try (Repository repo = openDummyRepository()) {
        LsRemoteCommand lsRemote = new LsRemoteCommand(repo);
        if (headsOnly) {
            lsRemote.setHeads(headsOnly);
        }
        if (tagsOnly) {
            lsRemote.setTags(tagsOnly);
        }
        lsRemote.setRemote(url);
        lsRemote.setCredentialsProvider(getProvider());
        Collection<Ref> refs = lsRemote.call();
            for (final Ref r : refs) {
                final String refName = r.getName();
                final ObjectId refObjectId =
                        r.getPeeledObjectId() != null ? r.getPeeledObjectId() : r.getObjectId();
                if (regexPattern != null) {
                    if (refName.matches(regexPattern)) {
                        references.put(refName, refObjectId);
                    }
                } else {
                    references.put(refName, refObjectId);
                }
            }
    } catch (JGitInternalException | GitAPIException | IOException e) {
        throw new GitException(e);
    }
    return references;
}
 
@Test
public void testHeadPointsAtCommitAboveStable() throws NoWorkTreeException,
        IOException, GitAPIException {
    tag("1.0.0");
    makeCommit();
    RevCommit commit = makeCommit();
    validateUnstable("1.0.0", 2, commit, Dirty.NO, DASH);
}
 
源代码20 项目: gocd   文件: CachedGoConfigIntegrationTest.java
@Test
public void writeFullConfigWithLockShouldUpdateReloadStrategyToEnsureReloadIsSkippedInAbsenceOfConfigFileChanges() throws GitAPIException, IOException {
    BasicCruiseConfig config = GoConfigMother.configWithPipelines("pipeline1");

    ConfigSaveState state = cachedGoConfig.writeFullConfigWithLock(new FullConfigUpdateCommand(config, goConfigService.configFileMd5()));

    String gitShaAfterSave = configRepository.getCurrentRevCommit().getName();
    assertThat(state).isEqualTo(ConfigSaveState.UPDATED);

    cachedGoConfig.forceReload();
    String gitShaAfterReload = configRepository.getCurrentRevCommit().getName();
    assertThat(gitShaAfterReload).isEqualTo(gitShaAfterSave);
}
 
源代码21 项目: GitFx   文件: GitFXGsonUtil.java
public static void initializeGitRepository(String serverName,
            String projectName,String projectPath){
        try{
        File localPath = new File(projectPath);
        Git git;
                git = Git.init().setDirectory(localPath).call();
        git.close();
        }
        catch(GitAPIException e){
//[LOG]            logger.debug("Error creating Git repository",e.getMessage());
        }
    }
 
源代码22 项目: proctor   文件: GitProctorCore.java
@Override
public void delete(final File testDefinitionDirectory) throws GitAPIException {
    for (final File file : testDefinitionDirectory.listFiles()) {
        git.rm().addFilepattern(testDefinitionsDirectory + "/" + testDefinitionDirectory.getName()
                + "/" + file.getName()).call();
    }
}
 
源代码23 项目: MergeProcessor   文件: GitMergeUtil.java
/**
 * {@code git fetch} {@code git reset --hard origin}
 */
private void revert() {
	try {
		repo.fetch().call();
		repo.reset().setMode(ResetType.HARD).setRef(mergeUnit.getBranchTarget()).call();
	} catch (GitAPIException e) {
		LOGGER.log(Level.SEVERE, String.format("Could no revert repository '%s'.", repoPath), e); //$NON-NLS-1$
	}
}
 
public void checkoutReleaseTrainBranch(String fileToRepo, String branch)
		throws GitAPIException, URISyntaxException {
	File file = file(fileToRepo);
	Git git = GitTestUtils.openGitProject(file);
	git.reset().setMode(ResetCommand.ResetType.HARD).call();
	if (new File(file, ".travis.yml").exists()) {
		new File(file, ".travis.yml").delete();
	}
	git.checkout().setForce(true).setName(branch).call();
}
 
源代码25 项目: rtc2gitcli   文件: GitMigrator.java
private void runGitGc() {
	try {
		git.gc().call();
	} catch (GitAPIException e) {
		e.printStackTrace();
	} finally {
		git.close();
	}
}
 
源代码26 项目: docker-maven-plugin   文件: TagMojo.java
@Override
protected void execute(DockerClient docker)
    throws MojoExecutionException, DockerException,
           IOException, InterruptedException, GitAPIException {

  if (skipDockerTag) {
    getLog().info("Skipping docker tag");
    return;
  }

  final String[] repoTag = parseImageName(newName);
  final String repo = repoTag[0];
  String tag = repoTag[1];

  if (useGitCommitId) {
    if (tag != null) {
      getLog().warn("Ignoring useGitCommitId flag because tag is explicitly set in image name ");
    } else {
      tag = new Git().getCommitId();
    }
  }

  final String normalizedName = isNullOrEmpty(tag) ? repo : String.format("%s:%s", repo, tag);
  getLog().info(String.format("Creating tag %s from %s", normalizedName, image));
  docker.tag(image, normalizedName, forceTags);

  final DockerBuildInformation buildInfo = new DockerBuildInformation(normalizedName, getLog());

  if (pushImage) {
    pushImage(docker, newName, null, getLog(), buildInfo, getRetryPushCount(),
        getRetryPushTimeout(), isSkipDockerPush());
  }

  writeImageInfoFile(buildInfo, tagInfoFile);
}
 
@Test
public void singleChanged_buildDownstream_enabled() throws GitAPIException, IOException {
    MavenProject changedModuleMock = addModuleMock(AID_MODULE_B, true);
    MavenProject dependentModuleMock = addModuleMock(AID_MODULE_B + "-dependent-jar", false);

    setUpstreamProjects(dependentModuleMock, changedModuleMock, moduleA);
    setDownstreamProjects(changedModuleMock, dependentModuleMock);

    // buildDownstream is enabled by default!

    underTest.act();

    verify(mavenSessionMock).setProjects(Arrays.asList(changedModuleMock, dependentModuleMock));
}
 
源代码28 项目: proctor   文件: GitProctorTest.java
@Test
public void testGetMatrix() throws StoreException, IOException, GitAPIException {
    final String revision1 =
            addTestDefinition("proc_tst", "author", "add a new test", DEFINITION_A);
    final String revision2 =
            addTestDefinition("proc_another_tst", "author", "add a another", DEFINITION_B);
    final String revision3 =
            deleteAllTestDefinitions("delete tests");

    assertThat(gitProctor.getTestMatrix(revision1).getTestMatrixDefinition().getTests())
            .hasSize(1)
            .containsEntry("proc_tst", DEFINITION_A);
    assertThat(gitProctor.getTestMatrix(revision1))
            .extracting(TestMatrixVersion::getAuthor, TestMatrixVersion::getDescription, TestMatrixVersion::getVersion)
            .containsExactly("author", "add a new test", revision1);

    assertThat(gitProctor.getTestMatrix(revision2).getTestMatrixDefinition().getTests())
            .hasSize(2)
            .containsEntry("proc_tst", DEFINITION_A)
            .containsEntry("proc_another_tst", DEFINITION_B);
    assertThat(gitProctor.getTestMatrix(revision2))
            .extracting(TestMatrixVersion::getAuthor, TestMatrixVersion::getDescription, TestMatrixVersion::getVersion)
            .containsExactly("author", "add a another", revision2);

    assertThat(gitProctor.getTestMatrix(revision3).getTestMatrixDefinition().getTests())
            .isEmpty();
    assertThat(gitProctor.getCurrentTestMatrix().getTestMatrixDefinition().getTests())
            .isEmpty();
    assertThat(gitProctor.getCurrentTestMatrix())
            .extracting(TestMatrixVersion::getDescription, TestMatrixVersion::getVersion)
            .containsExactly("delete tests", revision3);
}
 
源代码29 项目: Jpom   文件: BuildListController.java
@RequestMapping(value = "branchList.json", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody
public String branchList(
        @ValidatorConfig(@ValidatorItem(value = ValidatorRule.NOT_BLANK, msg = "仓库地址不正确")) String url,
        @ValidatorConfig(@ValidatorItem(value = ValidatorRule.NOT_BLANK, msg = "登录账号")) String userName,
        @ValidatorConfig(@ValidatorItem(value = ValidatorRule.NOT_BLANK, msg = "登录密码")) String userPwd) throws GitAPIException, IOException {
    List<String> list = GitUtil.getBranchList(url, userName, userPwd);
    return JsonMessage.getString(200, "ok", list);
}
 
@Test
public void nothingChanged_singleModule_withSubmodules_nonRecursive() throws GitAPIException, IOException {
    // note: a more realistic setup would require a proper parent/root
    moduleA.getModel().addModule("test");
    when(mavenExecutionRequestMock.isRecursive()).thenReturn(false);

    underTest.act();

    assertEquals(Collections.emptyList(), mavenSessionMock.getGoals(), "Unexpected goals");

    verify(mavenSessionMock, never()).setProjects(anyList());
    verify(moduleA).getModel();   // only once due to test setup

    assertProjectPropertiesEqual(moduleA, Collections.emptyMap());
}