mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-06 13:35:50 +01:00
Use ControlUtil#using() to handle RevWalk.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package util
|
||||
|
||||
import org.eclipse.jgit.api.Git
|
||||
import org.eclipse.jgit.revwalk.DepthWalk.RevWalk
|
||||
|
||||
/**
|
||||
* Provides control facilities.
|
||||
@@ -22,10 +23,6 @@ object ControlUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this method to use the Git object.
|
||||
* Repository resources are released certainly after processing.
|
||||
*/
|
||||
def using[T](git: Git)(f: Git => T): T =
|
||||
try {
|
||||
f(git)
|
||||
@@ -33,6 +30,13 @@ object ControlUtil {
|
||||
git.getRepository.close
|
||||
}
|
||||
|
||||
def using[T](revWalk: RevWalk)(f: RevWalk => T): T =
|
||||
try {
|
||||
f(revWalk)
|
||||
} finally {
|
||||
revWalk.release()
|
||||
}
|
||||
|
||||
def executeIf(condition: => Boolean)(action: => Unit): Boolean =
|
||||
if(condition){
|
||||
action
|
||||
|
||||
Reference in New Issue
Block a user