diff --git a/src/java/main/br/ufpe/cin/groundhog/scmclient/EmptyProjectAtDateException.java b/src/java/main/br/ufpe/cin/groundhog/scmclient/EmptyProjectAtDateException.java index 064988f..0e5b277 100644 --- a/src/java/main/br/ufpe/cin/groundhog/scmclient/EmptyProjectAtDateException.java +++ b/src/java/main/br/ufpe/cin/groundhog/scmclient/EmptyProjectAtDateException.java @@ -2,11 +2,16 @@ import br.ufpe.cin.groundhog.GroundhogException; +/** + * Thrown when a checkout operation is attempted for a date that corresponds + * to phase when the project has zero commits. + * @author fjsj + * + */ public class EmptyProjectAtDateException extends GroundhogException { private static final long serialVersionUID = 1L; public EmptyProjectAtDateException(String msg) { super(msg); } - } \ No newline at end of file diff --git a/src/java/main/br/ufpe/cin/groundhog/scmclient/GitClient.java b/src/java/main/br/ufpe/cin/groundhog/scmclient/GitClient.java index 4cf460e..eb74f03 100644 --- a/src/java/main/br/ufpe/cin/groundhog/scmclient/GitClient.java +++ b/src/java/main/br/ufpe/cin/groundhog/scmclient/GitClient.java @@ -28,6 +28,15 @@ public class GitClient { + /** + * Performs a clone operation for the given project URL and places the fetched code + * into the destination directory. + * @param url the project's URL + * @param destination + * @throws InvalidRemoteException + * @throws TransportException + * @throws GitAPIException + */ public void clone(String url, File destination) throws InvalidRemoteException, TransportException, GitAPIException { Repository rep = Git.cloneRepository(). @@ -37,8 +46,20 @@ public void clone(String url, File destination) rep.close(); } + /** + * Performs a checkout to the given Git repository + * @param repositoryFolder the repository where the checkout will be performed + * @param date + * @throws IOException + * @throws RefAlreadyExistsException + * @throws RefNotFoundException + * @throws InvalidRefNameException + * @throws CheckoutConflictException + * @throws GitAPIException + * @throws EmptyProjectAtDateException + */ public void checkout(File repositoryFolder, Date date) - throws IOException,RefAlreadyExistsException, RefNotFoundException, + throws IOException, RefAlreadyExistsException, RefNotFoundException, InvalidRefNameException, CheckoutConflictException, GitAPIException, EmptyProjectAtDateException { Git git = Git.open(repositoryFolder); @@ -69,13 +90,14 @@ public int compare(RevCommit c1, RevCommit c2) { return c1.getCommitterIdent().getWhen().compareTo(c2.getCommitterIdent().getWhen()); } }); - - // Workaround ahead, since JGit in Windows automatically - // adds ^M (Carriage Returns) to some files after, leaving the working tree dirty. - // JGit stash won't work and reset also not. So we need to commit! - // This commit doesn't affects metrics, since we do a checkout after it. - // To reproduce this bug, try to checkout https://github.com/playframework/ to 2012-05-01 12:00 - // TODO: report this bug to JGit team. + + /* Workaround ahead, since JGit in Windows automatically adds ^M (Carriage Returns) to some files after, + * leaving the working tree dirty. + * Neither JGit stash nor reset will work. So we need to commit! + * This commit doesn't affects metrics, since we do a checkout after it. + * To reproduce this bug, try to checkout https://github.com/playframework/ to 2012-05-01 12:00 + * TODO: report this bug to JGit team. + */ Set mods = git.status().call().getModified(); if (!mods.isEmpty()) { AddCommand addCmd = git.add(); @@ -85,7 +107,7 @@ public int compare(RevCommit c1, RevCommit c2) { addCmd.call(); git.commit().setMessage("Groundhog commit").call(); } - // workaround end. + /* workaround end.*/ git.checkout().setName("groundhog-analyze").setStartPoint(closest).setCreateBranch(true).call(); rep.close(); diff --git a/src/java/main/br/ufpe/cin/groundhog/scmclient/SVNClient.java b/src/java/main/br/ufpe/cin/groundhog/scmclient/SVNClient.java index c7b7c75..d92fa96 100644 --- a/src/java/main/br/ufpe/cin/groundhog/scmclient/SVNClient.java +++ b/src/java/main/br/ufpe/cin/groundhog/scmclient/SVNClient.java @@ -16,6 +16,12 @@ public SVNClient() { this.svn = SVNClientManager.newInstance(); } + /** + * Performs a checkout for a project with the given URL on the given destination directory + * @param url the project URL + * @param destination the destination directory + * @throws SVNException + */ public void checkout(String url, File destination) throws SVNException { SVNUpdateClient client = svn.getUpdateClient(); client.doCheckout(SVNURL.parseURIDecoded(url), @@ -26,6 +32,14 @@ public void checkout(String url, File destination) throws SVNException { false); } + /** + * Performs a checkout for a project with the given URL on the given destination directory with a + * specified SVN revision + * @param url the project URL + * @param destination the destination directory + * @param revision the SVN revision + * @throws SVNException + */ public void checkout(String url, File destination, SVNRevision revision) throws SVNException { SVNUpdateClient client = svn.getUpdateClient(); client.doCheckout(SVNURL.parseURIDecoded(url),