diff --git a/build.sc b/build.sc index dcae58a7d..0b87906a7 100644 --- a/build.sc +++ b/build.sc @@ -8,12 +8,19 @@ val isMasterCommit = sys.env.get("GITHUB_REPOSITORY") == Some("lihaoyi/Ammonite") && sys.env.get("GITHUB_REF").exists(x => x.endsWith("/master")) -val latestTaggedVersion = os.proc('git, 'describe, "--abbrev=0", "--tags").call().out.trim +val releaseArchiveVersion = sys.env.get("RELEASE_ARCHIVE_VERSION") -val gitHead = os.proc('git, "rev-parse", "HEAD").call().out.trim +val latestTaggedVersion = releaseArchiveVersion + .getOrElse(os.proc('git, 'describe, "--abbrev=0", "--tags").call().out.trim) -val commitsSinceTaggedVersion = { - os.proc('git, "rev-list", gitHead, "--not", latestTaggedVersion, "--count") +val gitHead = releaseArchiveVersion match { + case Some(ver) => ver + case None => os.proc('git, "rev-parse", "HEAD").call().out.trim +} + +val commitsSinceTaggedVersion = releaseArchiveVersion match { + case Some(_) => 0 + case None => os.proc('git, "rev-list", gitHead, "--not", latestTaggedVersion, "--count") .call() .out .trim @@ -35,10 +42,13 @@ val latestAssemblies = binCrossScalaVersions.map(amm(_).assembly) println("GITHUB REF " + sys.env.get("GITHUB_REF")) val (buildVersion, unstable) = scala.util.Try( - os.proc('git, 'describe, "--exact-match", "--tags", "--always", gitHead) - .call() - .out - .trim + releaseArchiveVersion match { + case Some(ver) => ver + case None => os.proc('git, 'describe, "--exact-match", "--tags", "--always", gitHead) + .call() + .out + .trim + } ).toOption match{ case None => val gitHash = os.proc("git", "rev-parse", "--short", "HEAD").call().out.trim diff --git a/ops/src/test/scala/test/ammonite/ops/ShelloutTests.scala b/ops/src/test/scala/test/ammonite/ops/ShelloutTests.scala index a90c34689..b757fcd88 100644 --- a/ops/src/test/scala/test/ammonite/ops/ShelloutTests.scala +++ b/ops/src/test/scala/test/ammonite/ops/ShelloutTests.scala @@ -63,7 +63,7 @@ object ShelloutTests extends TestSuite{ if(Unix()){ val res = %%('which, 'echo) val echoRoot = Path(res.out.string.trim) - assert(echoRoot == root/'bin/'echo) + assert(echoRoot == root/'bin/'echo || echoRoot == root/'usr/'bin/'echo) assert(%%(echoRoot, 'HELLO).out.lines == Seq("HELLO")) }