Skip to content

Commit

Permalink
use string interpolation instead of String.format
Browse files Browse the repository at this point in the history
  • Loading branch information
xuwei-k committed Oct 8, 2024
1 parent 6d82cea commit 0294152
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions src/main/scala/ReleaseExtra.scala
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ object ReleaseStateTransformations {
val vs = st.get(versions).getOrElse(sys.error("No versions are set! Was this release part executed before inquireVersions?"))
val selected = selectVersion(vs)

st.log.info("Setting version to '%s'." format selected)
st.log.info(s"Setting version to '${selected}'.")
val useGlobal = st.extract.get(releaseUseGlobalVersion)
val versionStr = (
if (useGlobal) {
Expand Down Expand Up @@ -164,7 +164,7 @@ object ReleaseStateTransformations {
val base = vcs(st).baseDir.getCanonicalFile
val sign = st.extract.get(releaseVcsSign)
val signOff = st.extract.get(releaseVcsSignOff)
val relativePath = IO.relativize(base, file).getOrElse("Version file [%s] is outside of this VCS repository with base directory [%s]!" format(file, base))
val relativePath = IO.relativize(base, file).getOrElse(s"Version file [${file}] is outside of this VCS repository with base directory [${base}]!")

vcs(st).add(relativePath) !! log
val status = vcs(st).status.!!.trim
Expand All @@ -190,16 +190,16 @@ object ReleaseStateTransformations {
@tailrec
def findTag(tag: String): Option[String] = {
if (vcs(st).existsTag(tag)) {
defaultChoice orElse SimpleReader.readLine("Tag [%s] exists! Overwrite, keep or abort or enter a new tag (o/k/a)? [a] " format tag) match {
defaultChoice orElse SimpleReader.readLine(s"Tag [${tag}] exists! Overwrite, keep or abort or enter a new tag (o/k/a)? [a] ") match {
case Some("" | "a" | "A") =>
sys.error("Tag [%s] already exists. Aborting release!" format tag)
sys.error(s"Tag [${tag}] already exists. Aborting release!")

case Some("k" | "K") =>
st.log.warn("The current tag [%s] does not point to the commit for this release!" format tag)
st.log.warn(s"The current tag [${tag}] does not point to the commit for this release!")
None

case Some("o" | "O") =>
st.log.warn("Overwriting a tag can cause problems if others have already seen the tag (see `%s help tag`)!" format vcs(st).commandName)
st.log.warn(s"Overwriting a tag can cause problems if others have already seen the tag (see `${vcs(st).commandName} help tag`)!")
Some(tag)

case Some(newTag) =>
Expand Down Expand Up @@ -237,7 +237,7 @@ object ReleaseStateTransformations {

val log = toProcessLogger(st)

st.log.info("Checking remote [%s] ..." format vcs(st).trackingRemote)
st.log.info(s"Checking remote [${vcs(st).trackingRemote}] ...")
if (vcs(st).checkRemote(vcs(st).trackingRemote) ! log != 0) {
defaultChoice orElse SimpleReader.readLine("Error while checking remote. Still continue (y/n)? [n] ") match {
case Yes() => // do nothing
Expand Down Expand Up @@ -277,7 +277,7 @@ object ReleaseStateTransformations {
case _ => st.log.warn("Remember to push the changes yourself!")
}
} else {
st.log.info("Changes were NOT pushed, because no upstream branch is configured for the local branch [%s]" format vcs(st).currentBranch)
st.log.info(s"Changes were NOT pushed, because no upstream branch is configured for the local branch [${vcs(st).currentBranch}]")
}
st
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/scala/Vcs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ class Git(val baseDir: File) extends Vcs with GitLike {

import Git.GitFlag

private lazy val trackingBranchCmd = cmd("config", "branch.%s.merge" format currentBranch)
private lazy val trackingBranchCmd = cmd("config", s"branch.${currentBranch}.merge")
private def trackingBranch: String = trackingBranchCmd.!!.trim.stripPrefix("refs/heads/")

private lazy val trackingRemoteCmd: ProcessBuilder = cmd("config", "branch.%s.remote" format currentBranch)
private lazy val trackingRemoteCmd: ProcessBuilder = cmd("config", s"branch.${currentBranch}.remote")
def trackingRemote: String = trackingRemoteCmd.!!.trim

def hasUpstream = trackingRemoteCmd ! devnull == 0 && trackingBranchCmd ! devnull == 0
Expand All @@ -144,7 +144,7 @@ class Git(val baseDir: File) extends Vcs with GitLike {

private def revParse(name: String) = cmd("rev-parse", name).!!.trim

def isBehindRemote = (cmd("rev-list", "%s..%s/%s".format(currentBranch, trackingRemote, trackingBranch)) !! devnull).trim.nonEmpty
def isBehindRemote = (cmd("rev-list", s"${currentBranch}..${trackingRemote}/${trackingBranch}") !! devnull).trim.nonEmpty

private def withFlags(flags: Seq[GitFlag])(args: String*): Seq[String] = {
val appended = flags.collect {
Expand Down Expand Up @@ -174,7 +174,7 @@ class Git(val baseDir: File) extends Vcs with GitLike {

private def pushCurrentBranch = {
val localBranch = currentBranch
cmd("push", trackingRemote, "%s:%s" format (localBranch, trackingBranch))
cmd("push", trackingRemote, s"${localBranch}:${trackingBranch}")
}

private def pushTags = cmd("push", "--tags", trackingRemote)
Expand Down

0 comments on commit 0294152

Please sign in to comment.