Skip to content

Commit

Permalink
FORGE-979 Fixed Forge plugin installation failures on Windows.
Browse files Browse the repository at this point in the history
The fix was to close the Git repository before deleting the directory housing it.
  • Loading branch information
VineetReynolds committed Jun 28, 2013
1 parent d929cef commit ef14731
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 10 additions & 1 deletion git-tools/src/main/java/org/jboss/forge/git/GitUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,17 @@ public static Ref createBranch(Git git, String branchName) throws RefAlreadyExis
return newBranch;
}

/**
* Closes a Git repository.
* Invoke this before deleting the Git repository on Windows to prevent errors due to unclosed file handles.
*
* @param repo The repository to close.
*/
public static 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 @@ -307,11 +307,12 @@ public void installFromGit(
buildDir = shell.getCurrentDirectory().createTempResource();
}

Git repo = null;
try
{
ShellMessages.info(out, "Checking out plugin source files to [" + buildDir.getFullyQualifiedName()
+ "] via 'git'");
Git repo = GitUtils.clone(buildDir, gitRepo);
repo = GitUtils.clone(buildDir, gitRepo);

Ref ref = null;
String targetRef = refName;
Expand Down Expand Up @@ -414,6 +415,7 @@ else if (refName != null)
}
finally
{
GitUtils.close(repo);
if (buildDir != null)
{
if (keepSources)
Expand Down

0 comments on commit ef14731

Please sign in to comment.