diff --git a/build.cmd b/build.cmd index 9785743..499652b 100644 --- a/build.cmd +++ b/build.cmd @@ -1,6 +1,11 @@ @echo off if "%DC%"=="" set DC=dmd +echo Generating version file... +set GITVER=unknown +for /f %%i in ('git describe') do set GITVER=%%i +echo enum dubVersion = "%GITVER%"; > source\dub\version_.d + echo Executing %DC%... %DC% -ofbin\dub.exe -g -debug -w -property -Isource curl.lib %* @build-files.txt if errorlevel 1 exit /b 1 diff --git a/build.sh b/build.sh index 80a6d90..3d8e65c 100755 --- a/build.sh +++ b/build.sh @@ -25,6 +25,11 @@ # adjust linker flags for dmd command line LIBS=`echo "$LIBS" | sed 's/^-L/-L-L/; s/ -L/ -L-L/g; s/^-l/-L-l/; s/ -l/ -L-l/g'` +echo Generating version file... +GITVER=$(git describe) || GITVER=unknown +echo enum dubVersion = "$GITVER"; > source/dub/version_.d + + echo Running $DC... $DC -ofbin/dub -g -debug -w -property -Isource $* $LIBS @build-files.txt echo DUB has been built as bin/dub. diff --git a/source/app.d b/source/app.d index da23361..c53ef59 100644 --- a/source/app.d +++ b/source/app.d @@ -18,6 +18,7 @@ import dub.package_; import dub.project; import dub.registry; +import dub.version_; import std.algorithm; import std.array; @@ -362,4 +363,5 @@ --local Install as in a sub folder of the current directory `); + logInfo("DUB version %s", dubVersion); } diff --git a/source/dub/utils.d b/source/dub/utils.d index 8df68f8..f3d2487 100644 --- a/source/dub/utils.d +++ b/source/dub/utils.d @@ -12,6 +12,7 @@ import dub.internal.vibecompat.core.log; import dub.internal.vibecompat.data.json; import dub.internal.vibecompat.inet.url; +import dub.version_; // todo: cleanup imports. import std.algorithm; @@ -96,7 +97,7 @@ auto conn = HTTP(); static if( is(typeof(&conn.verifyPeer)) ) conn.verifyPeer = false; - conn.addRequestHeader("User-Agent", "dub/0.7.13 (std.net.curl; +https://github.com/rejectedsoftware/dub)"); + conn.addRequestHeader("User-Agent", "dub/"~dubVersion~" (std.net.curl; +https://github.com/rejectedsoftware/dub)"); std.net.curl.download(url, filename, conn); }