Skip to content
Merged
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 .mill-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.12.15
0.12.16
42 changes: 36 additions & 6 deletions mill.bat
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ rem This script determines the Mill version to use by trying these sources
rem - env-variable `MILL_VERSION`
rem - local file `.mill-version`
rem - local file `.config/mill-version`
rem - `mill-version` from YAML fronmatter of current buildfile
rem - `mill-version` from YAML frontmatter of current buildfile
rem - if accessible, find the latest stable version available on Maven Central (https://repo1.maven.org/maven2)
rem - env-variable `DEFAULT_MILL_VERSION`
rem
Expand All @@ -23,7 +23,7 @@ rem this script downloads a binary file from Maven Central or Github Pages (this
rem into a cache location (%USERPROFILE%\.mill\download).
rem
rem Mill Project URL: https://github.com/com-lihaoyi/mill
rem Script Version: 1.0.0-M1-21-7b6fae-DIRTY892b63e8
rem Script Version: 1.0.5
rem
rem If you want to improve this script, please also contribute your changes back!
rem This script was generated from: dist/scripts/src/mill.bat
Expand All @@ -34,7 +34,7 @@ rem setlocal seems to be unavailable on Windows 95/98/ME
rem but I don't think we need to support them in 2019
setlocal enabledelayedexpansion

if [!DEFAULT_MILL_VERSION!]==[] ( set "DEFAULT_MILL_VERSION=0.12.15" )
if [!DEFAULT_MILL_VERSION!]==[] ( set "DEFAULT_MILL_VERSION=0.12.16" )

if [!MILL_GITHUB_RELEASE_CDN!]==[] ( set "MILL_GITHUB_RELEASE_CDN=" )

Expand Down Expand Up @@ -66,17 +66,47 @@ if [!MILL_VERSION!]==[] (
set /p MILL_VERSION=<.config\mill-version
) else (
if not "%MILL_BUILD_SCRIPT%"=="" (
for /f "tokens=1-2*" %%a in ('findstr /C:"//| mill-version:" %MILL_BUILD_SCRIPT%') do (
set "MILL_VERSION=%%c"
rem Find the line and process it
for /f "tokens=*" %%a in ('findstr /R /C:"//\|.*mill-version" "%MILL_BUILD_SCRIPT%"') do (
set "line=%%a"

rem --- 1. Replicate sed 's/.*://' ---
rem This removes everything up to and including the first colon
set "line=!line:*:=!"

rem --- 2. Replicate sed 's/#.*//' ---
rem Split on '#' and keep the first part
for /f "tokens=1 delims=#" %%b in ("!line!") do (
set "line=%%b"
)

rem --- 3. Replicate sed 's/['"]//g' ---
rem Remove all quotes
set "line=!line:'=!"
set "line=!line:"=!"

rem --- 4. NEW: Replicate sed's trim/space removal ---
rem Remove all space characters from the result. This is more robust.
set "MILL_VERSION=!line: =!"

rem We found the version, so we can exit the loop
goto :version_found
)

:version_found
rem no-op
) else (
rem no-op
)
)
)
)

if [!MILL_VERSION!]==[] set MILL_VERSION=%DEFAULT_MILL_VERSION%
if [!MILL_VERSION!]==[] (
echo No mill version specified. >&2
echo You should provide a version via a '//^| mill-version: ' comment or a '.mill-version' file. >&2
set MILL_VERSION=%DEFAULT_MILL_VERSION%
)

if [!MILL_DOWNLOAD_PATH!]==[] set MILL_DOWNLOAD_PATH=%USERPROFILE%\.mill\download

Expand Down
26 changes: 16 additions & 10 deletions millw
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# - env-variable `MILL_VERSION`
# - local file `.mill-version`
# - local file `.config/mill-version`
# - `mill-version` from YAML fronmatter of current buildfile
# - `mill-version` from YAML frontmatter of current buildfile
# - if accessible, find the latest stable version available on Maven Central (https://repo1.maven.org/maven2)
# - env-variable `DEFAULT_MILL_VERSION`
#
Expand All @@ -23,7 +23,7 @@
# into a cache location (~/.cache/mill/download).
#
# Mill Project URL: https://github.com/com-lihaoyi/mill
# Script Version: 1.0.0-M1-21-7b6fae-DIRTY892b63e8
# Script Version: 1.0.5
#
# If you want to improve this script, please also contribute your changes back!
# This script was generated from: dist/scripts/src/mill.sh
Expand All @@ -32,14 +32,8 @@

set -e

if [ "$1" = "--setup-completions" ] ; then
# Need to preserve the first position of those listed options
MILL_FIRST_ARG=$1
shift
fi

if [ -z "${DEFAULT_MILL_VERSION}" ] ; then
DEFAULT_MILL_VERSION=0.12.15
DEFAULT_MILL_VERSION="0.12.16"
fi


Expand Down Expand Up @@ -79,7 +73,19 @@ if [ -z "${MILL_VERSION}" ] ; then
elif [ -f ".config/mill-version" ] ; then
MILL_VERSION="$(tr '\r' '\n' < .config/mill-version | head -n 1 2> /dev/null)"
elif [ -n "${MILL_BUILD_SCRIPT}" ] ; then
MILL_VERSION="$(cat ${MILL_BUILD_SCRIPT} | grep '//[|] *mill-version: *' | sed 's;//| *mill-version: *;;')"
# `s/.*://`:
# This is a greedy match that removes everything from the beginning of the line up to (and including) the last
# colon (:). This effectively isolates the value part of the declaration.
#
# `s/#.*//`:
# This removes any comments at the end of the line.
#
# `s/['\"]//g`:
# This removes all single and double quotes from the string, wherever they appear (g is for "global").
#
# `s/^[[:space:]]*//; s/[[:space:]]*$//`:
# These two expressions trim any leading or trailing whitespace ([[:space:]] matches spaces and tabs).
MILL_VERSION="$(grep -E "//\|.*mill-version" "${MILL_BUILD_SCRIPT}" | sed -E "s/.*://; s/#.*//; s/['\"]//g; s/^[[:space:]]*//; s/[[:space:]]*$//")"
fi
fi

Expand Down