I'm trying to execute a command on Scala, but i'm getting an error
s"git --git-dir ${repository.localLocation.get.path}/.git log --format='%h %at %s' --no-decorate" !!
I'm getting an error exit status:
java.lang.RuntimeException: Nonzero exit value: 128
at scala.sys.package$.error(package.scala:27)
at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.$bang$bang(ProcessBuilderImpl.scala:134)
But when i'm running this via terminal it works perfectly:
git --git-dir='/var/folders/mk/dc2mnd7x3db1hnqm0vfg6b800000gn/T/XXHMjm7178261334218603127.tmp/.git' log --format='%h %at %s'
If i leave only one % part, it works properly.
Can anyone help me ?
答案 0 :(得分:1)
You should probably use the Seq[String]
variant, because you have space characters in your args that might be used to wrongly separate the arguments. Try
Seq("git", "--git-dir", s"${repository.localLocation.get.path}/.git",
"log", "--format='%h %at %s'", "--no-decorate").!!
Also note that you will see the single ticks ' in the output. You probably want "--format=%h %at %s"
.