/** * @return date in yyyy-mm-dd format */ public String getDateFormatted() { return DATE_FORMAT.format( getDate() ); }
/** * @return time in HH:mm:ss format */ public String getTimeFormatted() { return TIME_FORMAT.format( getDate() ); }
/** * @return time in HH:mm:ss format */ public String getTimeFormatted() { return TIME_FORMAT.format( getDate() ); }
/** * @return date in yyyy-mm-dd format */ public String getDateFormatted() { return DATE_FORMAT.format( getDate() ); }
/** * Add a change log entry to the list (if it's not already there) * with the given file. * * @param entry a {@link ChangeSet} to be added to the list if another * with the same key (p4 change number) doesn't exist already. * @param file a {@link ChangeFile} to be added to the entry */ private void addEntry( ChangeSet entry, ChangeFile file ) { // ---------------------------------------------------------------------- // Check that we are inside the requested date range // ---------------------------------------------------------------------- if ( startDate != null && entry.getDate().before( startDate ) ) { return; } if ( endDate != null && entry.getDate().after( endDate ) ) { return; } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- entry.addFile( file ); entries.add( entry ); }
/** * Add a change log entry to the list (if it's not already there) * with the given file. * * @param entry a {@link ChangeSet} to be added to the list if another * with the same key (p4 change number) doesn't exist already. * @param file a {@link ChangeFile} to be added to the entry */ private void addEntry( ChangeSet entry, ChangeFile file ) { // ---------------------------------------------------------------------- // Check that we are inside the requested date range // ---------------------------------------------------------------------- if ( startDate != null && entry.getDate().before( startDate ) ) { return; } if ( endDate != null && entry.getDate().after( endDate ) ) { return; } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- entry.addFile( file ); entries.add( entry ); }
private Date getLatestUpdateDate( ChangeLogScmResult changeLogScmResult ) { ChangeLogSet changeLogSet = changeLogScmResult.getChangeLog(); if ( changeLogSet != null ) { List<ChangeSet> changes = changeLogSet.getChangeSets(); if ( changes != null && !changes.isEmpty() ) { long date = 0; for ( ChangeSet change : changes ) { if ( date < change.getDate().getTime() ) { date = change.getDate().getTime(); } } if ( date != 0 ) { return new Date( date ); } } } return null; }
/** * Add a change log entry to the list (if it's not already there) * with the given file. * * @param entry a {@link ChangeSet} to be added to the list if another * with the same key doesn't exist already. If the entry's author * is null, the entry wont be added * @param file a {@link ChangeFile} to be added to the entry */ private void addEntry( ChangeSet entry, ChangeFile file ) { // do not add if entry is not populated if ( entry.getAuthor() == null ) { return; } // do not add if entry is out of date range if ( startDate != null && entry.getDate().before( startDate ) ) { return; } if ( endDate != null && entry.getDate().after( endDate ) ) { return; } entry.addFile( file ); entries.add( entry ); }
/** * Add a change log entry to the list (if it's not already there) * with the given file. * * @param entry a {@link ChangeSet} to be added to the list if another * with the same key doesn't exist already. If the entry's author * is null, the entry wont be added * @param file a {@link ChangeFile} to be added to the entry */ private void addEntry( ChangeSet entry, ChangeFile file ) { // do not add if entry is not populated if ( entry.getAuthor() == null ) { return; } // do not add if entry is out of date range if ( startDate != null && entry.getDate().before( startDate ) ) { return; } if ( endDate != null && entry.getDate().after( endDate ) ) { return; } entry.addFile( file ); entries.add( entry ); }
public List<ChangeSet> getModifications() throws ScmException { // Here there are one entry for each couple (changelist,file). We merge // entries to have only one entry per changelist // Date > ChangeSet Map<Date, ChangeSet> groupedEntries = new LinkedHashMap<Date, ChangeSet>(); for ( int i = 0; i < entries.size(); i++ ) { ChangeSet cs = (ChangeSet) entries.get( i ); ChangeSet hit = (ChangeSet) groupedEntries.get( cs.getDate() ); if ( hit != null ) { if ( cs.getFiles().size() != 1 ) { throw new ScmException( "Merge of entries failed. Bad entry size: " + cs.getFiles().size() ); } hit.addFile( (ChangeFile) cs.getFiles().get( 0 ) ); } else { groupedEntries.put( cs.getDate(), cs ); } } List<ChangeSet> result = new ArrayList<ChangeSet>(); result.addAll( groupedEntries.values() ); return result; }
public List<ChangeSet> getModifications() throws ScmException { // Here there are one entry for each couple (changelist,file). We merge // entries to have only one entry per changelist // Date > ChangeSet Map<Date, ChangeSet> groupedEntries = new LinkedHashMap<Date, ChangeSet>(); for ( int i = 0; i < entries.size(); i++ ) { ChangeSet cs = (ChangeSet) entries.get( i ); ChangeSet hit = (ChangeSet) groupedEntries.get( cs.getDate() ); if ( hit != null ) { if ( cs.getFiles().size() != 1 ) { throw new ScmException( "Merge of entries failed. Bad entry size: " + cs.getFiles().size() ); } hit.addFile( (ChangeFile) cs.getFiles().get( 0 ) ); } else { groupedEntries.put( cs.getDate(), cs ); } } List<ChangeSet> result = new ArrayList<ChangeSet>(); result.addAll( groupedEntries.values() ); return result; }
String key = ENTRY_KEY_TIMESTAMP_FORMAT.format( entry.getDate() ) + entry.getAuthor() + entry.getComment();
String key = ENTRY_KEY_TIMESTAMP_FORMAT.format( entry.getDate() ) + entry.getAuthor() + entry.getComment();
/** * 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; } }
assertEquals( 1, thirdResult.getChangeLog().getChangeSets().size() ); ChangeSet changeset = thirdResult.getChangeLog().getChangeSets().get( 0 ); assertTrue( changeset.getDate().after( timeBeforeSecond ) );