diff options
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/get-scala-commit-date | 16 | ||||
-rw-r--r-- | tools/get-scala-commit-date.bat | 24 | ||||
-rwxr-xr-x | tools/get-scala-commit-drift | 40 | ||||
-rw-r--r-- | tools/get-scala-commit-drift.bat (renamed from tools/get-scala-revision.bat) | 9 | ||||
-rwxr-xr-x | tools/get-scala-commit-sha (renamed from tools/get-scala-revision) | 14 | ||||
-rw-r--r-- | tools/get-scala-commit-sha.bat | 21 | ||||
-rwxr-xr-x | tools/verify-jar-cache | 10 |
7 files changed, 115 insertions, 19 deletions
diff --git a/tools/get-scala-commit-date b/tools/get-scala-commit-date new file mode 100755 index 0000000000..ef5b0f540d --- /dev/null +++ b/tools/get-scala-commit-date @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# +# Usage: get-scala-commit-date [dir] +# Figures out current commit date of a git clone. +# If no dir is given, current working dir is used. +# +# Example build version string: +# 20120312 +# + +[[ $# -eq 0 ]] || cd "$1" + +lastcommitdate=$(git log --format="%ci" HEAD | head -n 1 | cut -d ' ' -f 1) + +# 20120324 +echo "${lastcommitdate//-/}" diff --git a/tools/get-scala-commit-date.bat b/tools/get-scala-commit-date.bat new file mode 100644 index 0000000000..a07155533f --- /dev/null +++ b/tools/get-scala-commit-date.bat @@ -0,0 +1,24 @@ +@echo off +rem +rem Usage: get-scala-revison.bat [dir] +rem Figures out current scala commit date of a git clone. +rem +rem If no dir is given, current working dir is used. + +@setlocal +set _DIR= +if "%*"=="" ( + for /f "delims=;" %%i in ('cd') do set "_DIR=%%i" +) else ( + set "_DIR=%~1" +) +cd %_DIR% + +rem TODO - Check with a real windows user that this works! +if exist .git\NUL ( + for /f "tokens=1delims= " in ('git log --format="%ci" -1') do set commitdate=%%a + echo %commitdate% +) + +:end +@endlocal diff --git a/tools/get-scala-commit-drift b/tools/get-scala-commit-drift new file mode 100755 index 0000000000..4959826ec1 --- /dev/null +++ b/tools/get-scala-commit-drift @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +# +# Usage: get-scala-commit-drift [dir] +# Figures out current commit drift of a git clone. +# If no dir is given, current working dir is used. +# +# Example output string: +# 123 +# +# Build drift = # of commits since last tag. + +[[ $# -eq 0 ]] || cd "$1" + +ensure_tag () { + sha=$1 + rev=$2 + + [[ -n $(git tag -l $rev) ]] || { + git tag -a -m "generated by get-scala-revision" $rev $sha + } +} + +# Ensure some baseline tags are present so if this repository's +# tags are screwed up or stale, we should still have a reference +# point for a build string. +ensure_tag 58cb15c40d v2.10.0-M1 +ensure_tag 29f3eace1e v2.9.1 +ensure_tag b0d78f6b9c v2.8.2 + +# the closest tag, obtained separately because we have to +# reconstruct the string around the padded distance. +tag=$(git describe --tags --match 'v2*' --abbrev=0) + +# printf %016s is not portable for 0-padding, has to be a digit. +# so we're stuck disassembling it. +described=$(git describe --tags --match 'v2*' --abbrev=10) +suffix="${described##${tag}-}" +counter=$(echo $suffix | cut -d - -f 1) + +echo "$counter" diff --git a/tools/get-scala-revision.bat b/tools/get-scala-commit-drift.bat index 48c7cbd94f..ac289d3481 100644 --- a/tools/get-scala-revision.bat +++ b/tools/get-scala-commit-drift.bat @@ -1,7 +1,7 @@ @echo off rem -rem Usage: get-scala-revison.bat [dir] -rem Figures out current scala revision of a git clone. +rem Usage: get-scala-commit-drift.bat [dir] +rem Figures out current scala commit drift, of a clone. rem rem If no dir is given, current working dir is used. @@ -14,9 +14,8 @@ if "%*"=="" ( ) cd %_DIR% -if exist .git\NUL ( - git describe --abbrev=10 --always --tags -) +rem TODO - WRITE THIS +echo "TODO" :end @endlocal diff --git a/tools/get-scala-revision b/tools/get-scala-commit-sha index 4d97ec58ad..0abe31a53c 100755 --- a/tools/get-scala-revision +++ b/tools/get-scala-commit-sha @@ -1,11 +1,11 @@ #!/usr/bin/env bash # -# Usage: get-scala-revision [dir] -# Figures out current scala revision of a git clone. +# Usage: get-scala-commit-sha [dir] +# Figures out current commit sha of a git clone. # If no dir is given, current working dir is used. # # Example build version string: -# v2.10.0-M1-0098-g6f1c486d0b-2012-02-01 +# 6f1c486d0ba # [[ $# -eq 0 ]] || cd "$1" @@ -34,11 +34,7 @@ tag=$(git describe --tags --match 'v2*' --abbrev=0) # so we're stuck disassembling it. described=$(git describe --tags --match 'v2*' --abbrev=10) suffix="${described##${tag}-}" -counter=$(echo $suffix | cut -d - -f 1) hash=$(echo $suffix | cut -d - -f 2) +hash=${hash#g} -# remove any alphabetic characters before the version number -tag=$(echo $tag | sed "s/\([a-z_A-Z]*\)\(.*\)/\2/") - -# 2.10.0-M1-0098-g6f1c486d0b-2012-02-01 -printf "%s-%04d-%s-%s\n" "$tag" "$counter" "$hash" $(date "+%Y-%m-%d") +echo "$hash" diff --git a/tools/get-scala-commit-sha.bat b/tools/get-scala-commit-sha.bat new file mode 100644 index 0000000000..80d9aa34b1 --- /dev/null +++ b/tools/get-scala-commit-sha.bat @@ -0,0 +1,21 @@ +@echo off +rem +rem Usage: get-scala-commit-drift.bat [dir] +rem Figures out current scala commit drift, of a clone. +rem +rem If no dir is given, current working dir is used. + +@setlocal +set _DIR= +if "%*"=="" ( + for /f "delims=;" %%i in ('cd') do set "_DIR=%%i" +) else ( + set "_DIR=%~1" +) +cd %_DIR% + +rem TODO - truncate chars. +git log -1 --format="%T" + +:end +@endlocal diff --git a/tools/verify-jar-cache b/tools/verify-jar-cache index 1e86264ecb..8a376a6987 100755 --- a/tools/verify-jar-cache +++ b/tools/verify-jar-cache @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # Discovers files whose sha sum does not match the # sha embedded in their directory name from ~/.sbt/cache/scala. @@ -9,14 +9,14 @@ cd ~/.sbt/cache/scala unset failed unset removal -[[ $1 == "-f" ]] && removal=true +[[ "$1" == "-f" ]] && removal=true for file in $(find . -type f); do sha=$(echo "${file:2}" | sed 's/\/.*$//') sum=$(shasum "$file" | sed 's/ .*$//') if [[ $sum != $sha ]]; then failed=true - if [[ -n $removal ]]; then + if [[ -n "$removal" ]]; then echo "Removing corrupt file $file, shasum=$sum" rm -rf $sha else @@ -25,9 +25,9 @@ for file in $(find . -type f); do fi done -if [[ -z $failed ]]; then +if [[ -z "$failed" ]]; then echo "All cached files match their shas." -elif [[ -z $removal ]]; then +elif [[ -z "$removal" ]]; then echo "" echo "Run again with -f to remove the corrupt files." fi |