mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-09 15:05:50 +01:00
Improve checkConflict
* Delete temporary RefSpec after checkConflict * mergeguide use checkconflictInPullRequest instead of checkconflict
This commit is contained in:
@@ -3,6 +3,7 @@ package util
|
||||
import org.eclipse.jgit.api.Git
|
||||
import org.eclipse.jgit.revwalk.RevWalk
|
||||
import org.eclipse.jgit.treewalk.TreeWalk
|
||||
import org.eclipse.jgit.transport.RefSpec
|
||||
|
||||
/**
|
||||
* Provides control facilities.
|
||||
@@ -37,6 +38,17 @@ object ControlUtil {
|
||||
def using[T](treeWalk: TreeWalk)(f: TreeWalk => T): T =
|
||||
try f(treeWalk) finally treeWalk.release()
|
||||
|
||||
|
||||
def withTmpRefSpec[T](ref: RefSpec, git: Git)(f: RefSpec => T): T = {
|
||||
try {
|
||||
f(ref)
|
||||
} finally {
|
||||
val refUpdate = git.getRepository.updateRef(ref.getDestination)
|
||||
refUpdate.setForceUpdate(true)
|
||||
refUpdate.delete()
|
||||
}
|
||||
}
|
||||
|
||||
def executeIf(condition: => Boolean)(action: => Unit): Boolean =
|
||||
if(condition){
|
||||
action
|
||||
|
||||
Reference in New Issue
Block a user