Remove some functions from ControlUtil.

This commit is contained in:
takezoe
2013-12-15 04:21:39 +09:00
parent ac884bd7c3
commit 0e9bf59c0f
7 changed files with 34 additions and 38 deletions

View File

@@ -40,22 +40,14 @@ object ControlUtil {
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 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
true
} else false
def optionIf[T](condition: => Boolean)(action: => Option[T]): Option[T] =
if(condition) action else None
}

View File

@@ -79,9 +79,9 @@ object JGitUtil {
}
val description = defining(fullMessage.trim.indexOf("\n")){ i =>
optionIf(i >= 0){
if(i >= 0){
Some(fullMessage.trim.substring(i).trim)
}
} else None
}
}

View File

@@ -130,8 +130,8 @@ object LDAPUtil {
private def findMailAddress(conn: LDAPConnection, userDN: String, mailAttribute: String): Option[String] =
defining(conn.search(userDN, LDAPConnection.SCOPE_BASE, null, Array[String](mailAttribute), false)){ results =>
optionIf (results.hasMore) {
if(results.hasMore) {
Option(results.next.getAttribute(mailAttribute)).map(_.getStringValue)
}
} else None
}
}