Skip to content

Commit 54749bc

Browse files
IanButterworthKristofferC
authored andcommitted
Don't trigger full rebuild if git is dirty (#60023)
(cherry picked from commit 6f2f7f5)
1 parent bb9d31e commit 54749bc

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

base/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
/uv_constants.jl
88
/version_git.jl
99
/version_git.jl.phony
10+
/version_git_dirty
1011
/userimg.jl
1112
/JuliaSyntax

base/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,4 +306,5 @@ clean:
306306
-rm -f $(BUILDDIR)/file_constants.jl
307307
-rm -f $(BUILDDIR)/version_git.jl
308308
-rm -f $(BUILDDIR)/version_git.jl.phony
309+
-rm -f $(BUILDDIR)/version_git_dirty
309310
-rm -f $(build_private_libdir)/lib*.$(SHLIB_EXT)*

base/version_git.sh

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
echo "# This file was autogenerated by base/version_git.sh"
77
echo "struct GitVersionInfo"
88
echo " commit::String"
9-
echo " commit_short::String"
9+
echo " commit_short_raw::String"
1010
echo " branch::String"
1111
echo " build_number::Int"
1212
echo " date_string::String"
@@ -17,6 +17,24 @@ echo " build_system_commit::String"
1717
echo " build_system_commit_short::String"
1818
echo "end"
1919
echo ""
20+
echo "function Base.getproperty(info::GitVersionInfo, s::Symbol)"
21+
echo " if s === :commit_short"
22+
echo " commit = getfield(info, :commit_short_raw)"
23+
echo " dirty_file = joinpath(Sys.BINDIR, Base.DATAROOTDIR, \"julia\", \"base\", \"version_git_dirty\")"
24+
echo " dirty_str = try"
25+
echo " read(dirty_file, String)"
26+
echo " catch"
27+
echo " \"\""
28+
echo " end"
29+
echo " if strip(dirty_str) == \"true\""
30+
echo " return commit * \"*\""
31+
echo " end"
32+
echo " return commit"
33+
echo " else"
34+
echo " return getfield(info, s)"
35+
echo " end"
36+
echo "end"
37+
echo ""
2038

2139
cd $1
2240

@@ -38,8 +56,9 @@ git_time=$(git log -1 --pretty=format:%ct)
3856
commit=$(git rev-parse HEAD)
3957
commit_short=$(git rev-parse --short HEAD)
4058
if [ -n "$(git status --porcelain)" ]; then
41-
# append dirty mark '*' if the repository has uncommitted changes
42-
commit_short="$commit_short"*
59+
dirty="true"
60+
else
61+
dirty="false"
4362
fi
4463

4564
# Our CI system checks commits out as a detached head, and so we must
@@ -117,3 +136,7 @@ echo " $fork_master_timestamp.0,"
117136
echo " \"$build_system_commit\","
118137
echo " \"$build_system_commit_short\","
119138
echo ")"
139+
140+
# Write dirty status to a separate file to avoid triggering rebuilds
141+
# when only the dirty status changes
142+
echo "$dirty" > version_git_dirty

stdlib/InteractiveUtils/src/InteractiveUtils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ See also: [`VERSION`](@ref).
102102
"""
103103
function versioninfo(io::IO=stdout; verbose::Bool=false)
104104
println(io, "Julia Version $VERSION")
105-
if !isempty(Base.GIT_VERSION_INFO.commit_short)
105+
if !isempty(Base.GIT_VERSION_INFO.commit_short_raw)
106106
println(io, "Commit $(Base.GIT_VERSION_INFO.commit_short) ($(Base.GIT_VERSION_INFO.date_string))")
107107
end
108108
official_release = Base.TAGGED_RELEASE_BANNER == "Official https://julialang.org release"

0 commit comments

Comments
 (0)