List of usage examples for org.eclipse.jgit.api GarbageCollectCommand setExpire
public GarbageCollectCommand setExpire(Date expire)
expire
will not be pruned. From source file:org.kuali.student.git.importer.GitImporterParseOptions.java
License:Educational Community License
@Override public void onRevisionContentLength(long currentRevision, long contentLength, long propContentLength, ReadLineData lineData) {// w w w . j av a2 s . co m // flush logs for the last revision blobLog.flush(); copyFromSkippedLog.flush(); vetoLog.flush(); // for any branch with a blob added create a git commit object pointing // at the git tree for the change. if (this.currentRevision != -1) flushPendingBranchCommits(); if (gcEnabled && this.currentRevision != 0 && this.currentRevision % 500 == 0) { // every five hundred revisions garbage collect the repository to // keep it fast log.info("Garbage collecting git repository"); if (externalGitCommandPath != null) { ExternalGitUtils.runGarbageCollection(externalGitCommandPath, repo, System.out); } else { try { GarbageCollectCommand gc = new Git(repo).gc(); // should not matter but anything loose can be collected. gc.setExpire(new Date()); gc.call(); } catch (GitAPIException e) { } } /* * Make sure JGit knows where the ref is located after loose refs are put into the pack file. */ repo.getRefDatabase().refresh(); } // if (gcEnabled && this.currentRevision != 0 && this.currentRevision % // 10000 == 0) { // // repack the revision map file every 10000 revs // try { // revisionMapper.repackMapFile(); // } catch (IOException e) { // throw new RuntimeException("failed to repack revision mapper", e); // } // } if (this.currentRevision == -1) { /* * In the initialization case check that we haven't already imported this revision. * * This will prevent clobbering an existing import. */ try { List<SvnRevisionMap> knownHeads = revisionMapper.getRevisionHeads(currentRevision); if (knownHeads != null && knownHeads.size() > 0) throw new RuntimeException( "Aborting: Target Git Repository(" + repo.getDirectory().getAbsolutePath() + ") already contains an export of revision: " + currentRevision); } catch (IOException e) { throw new RuntimeException( "failed to check existing revision heads for revision = " + currentRevision, e); } } this.currentRevision = currentRevision; log.info("starting on Revision: " + currentRevision); // at this point we should be able to read // propContentLength and parse out the try { Map<String, String> revisionProperties = org.kuali.student.common.io.IOUtils .extractRevisionProperties(inputStream, propContentLength, contentLength); // read out the author and commit message String author = revisionProperties.get("svn:author"); String commitDate = revisionProperties.get("svn:date"); String commitMessage = revisionProperties.get("svn:log"); String userName = author; if (userName == null) userName = "unknown"; String emailAddress = userName + "@kuali.org"; Date actualCommitDate = null; if (commitDate != null) { actualCommitDate = GitImporterDateUtils.convertDateString(commitDate); } else { log.warn("Missing commit date"); if (commitMessage == null) { commitMessage = MISSING_COMMIT_DATE_MESSAGE; } else { commitMessage = commitMessage + "\n" + MISSING_COMMIT_DATE_MESSAGE; } /* * Get the commit time of the previous commit and add 5 minutes * to it. */ List<SvnRevisionMap> heads = revisionMapper.getRevisionHeads(currentRevision - 1L); if (heads.size() == 0) { actualCommitDate = new DateTime(0L).toDate(); } else { SvnRevisionMap head = heads.get(0); RevWalk rw = new RevWalk(repo); RevCommit lastCommit = rw.parseCommit(ObjectId.fromString(head.getCommitId())); DateTime dt = new DateTime(lastCommit.getAuthorIdent().getWhen()).plusMinutes(5); actualCommitDate = dt.toDate(); } } TimeZone tz = GitImporterDateUtils.extractTimeZone(actualCommitDate); commitData = new GitCommitData(new PersonIdent(userName, emailAddress, actualCommitDate, tz), commitMessage); nodeProcessor.setCommitData(commitData); // also consider copyfrom or other details that // suggest a merge at this point. } catch (Exception e) { throw new RuntimeException("onRevisionContentLength failed to read revision properties.", e); } }