org.apache.maven.scm.command.changelog.ChangeLogScmResult Java Examples

The following examples show how to use org.apache.maven.scm.command.changelog.ChangeLogScmResult. 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: ScmSpy.java    From vertx-maven-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * This method extracts the simple metadata such as revision, lastCommitTimestamp of the commit/hash, author of the commit
 * from the Changelog available in the SCM repository
 * @param scmUrl - the SCM url to get the SCM connection
 * @param workingDir - the Working Copy or Directory of the SCM repo
 * @return a {@link Map<ExtraManifestKeys,String>} of values extracted form the changelog, with Keys from {@link ExtraManifestKeys}
 * @throws IOException - any error that might occur while manipulating the SCM Changelog
 * @throws ScmException - other SCM related exceptions
 */
public Map<ExtraManifestKeys, String> getChangeLog(String scmUrl, File workingDir) throws IOException, ScmException {
    Map<ExtraManifestKeys, String> changeLogMap = new HashMap<>();
    ScmRepository scmRepository = scmManager.makeScmRepository(scmUrl);
    ChangeLogScmResult scmResult = scmManager.changeLog(new ChangeLogScmRequest(scmRepository,
        new ScmFileSet(workingDir, "*")));
    if (scmResult.isSuccess()) {
        List<ChangeSet> changeSetList = scmResult.getChangeLog().getChangeSets();
        if (changeSetList != null && !changeSetList.isEmpty()) {
            //get the latest changelog
            ChangeSet changeSet = changeSetList.get(0);
            changeLogMap.put(ExtraManifestKeys.SCM_TYPE, getScmType(scmUrl));
            changeLogMap.put(ExtraManifestKeys.SCM_REVISION, changeSet.getRevision());
            changeLogMap.put(ExtraManifestKeys.LAST_COMMIT_TIMESTAMP,
                manifestTimestampFormat(changeSet.getDate()));
            changeLogMap.put(ExtraManifestKeys.SCM_AUTHOR, changeSet.getAuthor());
        }
    }

    return changeLogMap;
}
 
Example #2
Source File: ScmSpy.java    From vertx-maven-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * This method extracts the simple metadata such as revision, lastCommitTimestamp of the commit/hash, author of the commit
 * from the Changelog available in the SCM repository
 * @param scmUrl - the SCM url to get the SCM connection
 * @param workingDir - the Working Copy or Directory of the SCM repo
 * @return a {@link Map<String,String>} of values extracted form the changelog, with Keys from {@link ExtraManifestKeys}
 * @throws IOException - any error that might occur while manipulating the SCM Changelog
 * @throws ScmException - other SCM related exceptions
 */
public Map<String, String> getChangeLog(String scmUrl, File workingDir) throws IOException, ScmException {
    Map<String, String> changeLogMap = new HashMap<>();
    ScmRepository scmRepository = scmManager.makeScmRepository(scmUrl);
    ChangeLogScmResult scmResult = scmManager.changeLog(new ChangeLogScmRequest(scmRepository,
        new ScmFileSet(workingDir, "*")));
    if (scmResult.isSuccess()) {
        List<ChangeSet> changeSetList = scmResult.getChangeLog().getChangeSets();
        if (changeSetList != null && !changeSetList.isEmpty()) {
            //get the latest changelog
            ChangeSet changeSet = changeSetList.get(0);
            changeLogMap.put(ExtraManifestKeys.scmType.name(), getScmType(scmUrl));
            changeLogMap.put(ExtraManifestKeys.scmRevision.name(), changeSet.getRevision());
            changeLogMap.put(ExtraManifestKeys.lastCommitTimestamp.name(),
                manifestTimestampFormat(changeSet.getDate()));
            changeLogMap.put(ExtraManifestKeys.author.name(), changeSet.getAuthor());
        }
    }

    return changeLogMap;
}
 
Example #3
Source File: ScmMojo.java    From pitest with Apache License 2.0 6 votes vote down vote up
private Set<String> pathsAffectedByChange(ChangeLogScmRequest scmRequest, Set<ScmFileStatus> statusToInclude, int limit) throws ScmException {
  Set<String> affected = new LinkedHashSet<>();
  ChangeLogScmResult changeLogScmResult = this.manager.changeLog(scmRequest);
  if (changeLogScmResult.isSuccess()) {
    List<ChangeSet> changeSets = limit(changeLogScmResult.getChangeLog().getChangeSets(),limit);
    for (ChangeSet change : changeSets) {
      List<ChangeFile> files = change.getFiles();
      for (final ChangeFile changeFile : files) {
        if (statusToInclude.contains(changeFile.getAction())) {
          affected.add(changeFile.getName());
        }
      }
    }
  }
  return affected;
}
 
Example #4
Source File: ScmMojoTest.java    From pitest with Apache License 2.0 4 votes vote down vote up
private void givenChangeLogWithLastCommit() throws ScmException {
  when(this.manager.changeLog(any(ChangeLogScmRequest.class)))
          .thenReturn(new ChangeLogScmResult("", new ChangeLogSet(Arrays.asList(aChangeSetWithAddedFile()),
                  new Date(), new Date())));
}