Skip to content

Commit

Permalink
Finishing writing Javadocs for the br.ufpe.cin.groundhog.codehistory …
Browse files Browse the repository at this point in the history
…package. Related to #20.
  • Loading branch information
Rodrigo Alves Vieira committed May 4, 2013
1 parent b7d2deb commit d11006a
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

import br.ufpe.cin.groundhog.GroundhogException;

/**
* Thrown when a check out cannot be performed
* @author fjsj
*/
public class CheckoutException extends GroundhogException {
private static final long serialVersionUID = 1L;

public CheckoutException(Throwable e) {
super(e);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
public interface CodeHistory {

/**
* Checkos out the given project according to the given date. Returns a new temporary folder
* Checks out the given project according to the given date. Returns a new temporary folder
* with the project source code version at or before date. This variation of this method should
* be used when the SCM revision history is centralized within a URL (like SVN).
* @param project project name
* @param url project SCM url, usually set by a ForgeCrawler subclass
* @param url project SCM URL, usually set by a ForgeCrawler subclass
* @param date date to checkout
* @return a new temporary folder with the project source code state at the given date.
* @throws Exception when something nasty happens
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ protected void configure() {
bind(SFCodeHistory.class).in(Singleton.class);
bind(SvnCodeHistory.class).in(Singleton.class);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
import br.ufpe.cin.groundhog.scmclient.GitClient;
import br.ufpe.cin.groundhog.util.FileUtil;

/**
* The code history analysis implementation for the Git SCM
* @author fjsj
*/
public class GitCodeHistory implements CodeHistory {

private final GitClient gitClient;

@Inject
Expand All @@ -24,9 +27,15 @@ public File checkoutToDate(String project, String url, Date date) {
}

@Override
public File checkoutToDate(String project, File repositoryFolder,
final Date date) throws CheckoutException,
EmptyProjectAtDateException {
/**
* Creates a directory with the name of the project, moves the content of the repository folder into it
* and performs the SCM checkout on this new directory
* @param project the name of the project
* @param repositoryFolder the repository where the source code is located
* @param date the date on which the checkout will be based
*/
public File checkoutToDate(String project, File repositoryFolder, final Date date)
throws CheckoutException, EmptyProjectAtDateException {
try {
File projectFolder = new File(FileUtil.getInstance()
.createTempDir(), project);
Expand Down
12 changes: 12 additions & 0 deletions src/java/main/br/ufpe/cin/groundhog/codehistory/SFCodeHistory.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
import br.ufpe.cin.groundhog.scmclient.EmptyProjectAtDateException;
import br.ufpe.cin.groundhog.util.FileUtil;

/**
* The code history analysis implementation for SourceForge
* @author fjsj
*/
public class SFCodeHistory implements CodeHistory {

@Override
Expand All @@ -20,6 +24,13 @@ public File checkoutToDate(String project, String url, Date date) {

// TODO: how to know if the single extracted file is really the source code of the project
// and isn't a library or just a part?
/**
*
* @param project
* @param repositoryFolder
* @param Date
* @throws EmptyProjectAtDateException
*/
@Override
public File checkoutToDate(String project, File repositoryFolder, Date date) throws EmptyProjectAtDateException {
long dateLong = date.getTime();
Expand All @@ -45,6 +56,7 @@ public File checkoutToDate(String project, File repositoryFolder, Date date) thr
}
}
}

if (closest != null) {
File projectFolder = new File(FileUtil.getInstance().createTempDir(), project);
DefaultExtractor.getInstance().extractFile(closest, projectFolder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,28 @@
import com.google.inject.Inject;
import com.google.inject.Injector;

/**
* The code history analysis implementation for the SVN SCM
* @author fjsj
*/
public class SvnCodeHistory implements CodeHistory {

private final SVNClient svnClient;

@Inject
public SvnCodeHistory(SVNClient svnClient) {
this.svnClient = svnClient;
}

/**
* Performs a check out in the project based on the informed URL and date
*/
@Override
public File checkoutToDate(String project, String url, Date date)
throws CheckoutException {
try {
File projectFolder = new File(FileUtil.getInstance()
.createTempDir(), project);
svnClient.checkout(url, projectFolder, SVNRevision.create(date));
this.svnClient.checkout(url, projectFolder, SVNRevision.create(date));
return projectFolder;
} catch (SVNException e) {
throw new CheckoutException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

import br.ufpe.cin.groundhog.GroundhogException;

/**
* Thrown when an attempt to use an unsupported SCM is done
* @author fjsj
*/
public class UnsupportedSCMException extends GroundhogException {
private static final long serialVersionUID = 1L;

Expand Down

0 comments on commit d11006a

Please sign in to comment.