Skip to content

Fix #1207: Add Batch scripts and improve Shell scripts #3720

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion project/VersionUtil.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ object VersionUtil {
def executeScript(scriptName: String) = {
val cmd =
if (System.getProperty("os.name").toLowerCase.contains("windows"))
s"cmd.exe /c project\\scripts\\build\\$scriptName.bat -p"
s"cmd.exe /c project\\scripts\\build\\$scriptName.bat"
else s"project/scripts/build/$scriptName"
Process(cmd).lines.head.trim
}
Expand Down
12 changes: 8 additions & 4 deletions project/scripts/build/get-scala-commit-date
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@
# 20120312
#

[[ $# -eq 0 ]] || cd "$1"
# Exit immediately if any command returns a non-zero status.
set -eo pipefail

lastcommitdate=$(git log --format="%ci" HEAD | head -n 1 | cut -d ' ' -f 1)
[[ $# -eq 0 ]] || cd "$1"

# 20120324
echo "${lastcommitdate//-/}"
# A better version could use `git log -n 1 --pretty='format:%cd' --date=format:'%Y%m%d'`.
# But it requires everybody to use Git v2.6.0 or above.
last_commit_date=$(git log -1 --format="%ci" HEAD | cut -d ' ' -f 1)
# remove "-"
echo "${last_commit_date//-/}"
19 changes: 11 additions & 8 deletions project/scripts/build/get-scala-commit-date.bat
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
@echo off
for %%X in (bash.exe) do (set FOUND=%%~$PATH:X)
if defined FOUND (
bash "%~dp0\get-scala-commit-date" 2>NUL
) else (
rem echo this script does not work with cmd.exe. please, install bash
echo unknown
exit 1
)
rem See more documentation in the corresponding Shell script.

if not [%1]==[] cd /d %1

for /f "delims=" %%s in ('git log -1 --format^=""%%ci"" HEAD') do set last_commit_date_time=%%s
rem If some errors happen; e.g. Git is not installed.
if not defined last_commit_date_time exit 1
rem remove time
for /f "tokens=1 delims= " %%s in ("%last_commit_date_time%") do set last_commit_date=%%s
rem remove "-"
echo %last_commit_date:-=%
9 changes: 4 additions & 5 deletions project/scripts/build/get-scala-commit-sha
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
# If no dir is given, current working dir is used.
#
# Example build version string:
# 6f1c486d0ba
# b01f13ec4a3ac15e5e922cc0019169e8563ffc8d
#

# Exit immediately if any command returns a non-zero status.
set -eo pipefail

[[ $# -eq 0 ]] || cd "$1"

# printf %016s is not portable for 0-padding, has to be a digit.
# so we're stuck disassembling it.
hash=$(git log -1 --format="%H" HEAD)
hash=${hash#g}
hash=${hash:0:10}
echo "$hash"
16 changes: 8 additions & 8 deletions project/scripts/build/get-scala-commit-sha.bat
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@echo off
for %%X in (bash.exe) do (set FOUND=%%~$PATH:X)
if defined FOUND (
bash "%~dp0\get-scala-commit-sha" 2>NUL
) else (
rem echo this script does not work with cmd.exe. please, install bash
echo unknown
exit 1
)
rem See more documentation in the corresponding Shell script.

if not [%1]==[] cd /d %1

for /f "delims=" %%s in ('git log -1 --format^=""%%H"" HEAD') do set hash=%%s
rem If some errors happen; e.g. Git is not installed.
if not defined hash exit 1
echo %hash%