Skip to content

Commit

Permalink
Fixed some minor bugs in GIT addon
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Apr 4, 2014
1 parent 9aa8c11 commit 76578b7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
*/
public class GitUtilsImpl implements GitUtils
{

@Override
public Git clone(final DirectoryResource dir, final String repoUri) throws GitAPIException
{
Expand Down Expand Up @@ -89,7 +89,7 @@ public Ref checkout(final Git git, final String remote, final boolean createBran
}

@Override
public Ref checkout(final Git git, final Ref localRef, final SetupUpstreamMode mode,
public Ref checkout(final Git git, final Ref localRef, final SetupUpstreamMode mode,
final boolean force) throws GitAPIException
{
CheckoutCommand checkout = git.checkout();
Expand Down Expand Up @@ -390,6 +390,9 @@ public Ref createBranch(Git git, String branchName) throws GitAPIException
@Override
public void close(final Git repo)
{
repo.getRepository().close();
if (repo != null)
{
repo.getRepository().close();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/**
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
* @author <a href="mailto:jevgeni.zelenkov@gmail.com">Jevgeni Zelenkov</a>
*
*
*/
public class GitCloneCommand extends AbstractGitCommand
{
Expand Down Expand Up @@ -63,8 +63,15 @@ public Result execute(UIExecutionContext context) throws Exception
{
cloneFolder.mkdirs();
}
Git clone = gitUtils.clone(cloneFolder, uri.getValue());
gitUtils.close(clone);
Git clone = null;
try
{
clone = gitUtils.clone(cloneFolder, uri.getValue());
}
finally
{
gitUtils.close(clone);
}
context.getUIContext().setSelection(cloneFolder);
return Results.success();
}
Expand All @@ -73,9 +80,10 @@ public Result execute(UIExecutionContext context) throws Exception
public void validate(UIValidationContext validator)
{
DirectoryResource folder = targetDirectory.getValue();
if (folder.exists() && (!folder.isDirectory() || !folder.listResources().isEmpty()))
if (folder == null || (folder.exists() && (!folder.isDirectory() || !folder.listResources().isEmpty())))
{
validator.addValidationError(targetDirectory, "The specified target directory should not exist or should be empty directory");
validator.addValidationError(targetDirectory,
"The specified target directory should not exist or should be empty directory");
}
}

Expand Down

0 comments on commit 76578b7

Please sign in to comment.