JIRA 4.0 : How do I extract CVS commits for an issue
This page last changed on Mar 31, 2006 by donna@atlassian.com.
This code snippet was extracted from the DefaultActionManager class in JIRA's source code: /** * Retrieves all of the commits for this issue from ALL of the repositories associated with the issue's project * * @param issue * @param remoteUser */ public List getCommits(GenericValue issue, User remoteUser) throws GenericEntityException, RepositoryException { List commits = new ArrayList(); if (issue == null) throw new IllegalArgumentException("Issue cannot be null."); if (!"Issue".equals(issue.getEntityName())) throw new IllegalArgumentException("Entity must be of type Issue"); if (!hasPermission(issue, remoteUser)) { // If the user does not have the reuqited permission, do not return any information. return Collections.EMPTY_LIST; } Collection repositories = getRepositories(issue); for (Iterator iterator = repositories.iterator(); iterator.hasNext();) { Repository repository = (Repository) iterator.next(); try { List coms = repository.getCommitsForIssue(issue.getString("key")); for (int i = 0; i < coms.size(); i++) { commits.add(new Commit((VCSCommit) coms.get(i), remoteUser, repository.getName(), repository.getRepositoryBrowser())); } } catch (OutOfMemoryError e) { // Add an issue action that represents OutOFMemeory error commits.add(new OutOfMemoryCommitIssueAction(remoteUser, new Timestamp(System.currentTimeMillis()), repository.getName())); } } // Sort by date Collections.sort(commits); return commits; } |
![]() |
Document generated by Confluence on Oct 06, 2009 00:31 |