Skip to content

Commit c629eb2

Browse files
committed
Fix #5218, calculate age of Julia checkout in banner() function
After static compillation of base Julia was implemented, the startup banner showed the age of the newest commit in (origin/)master at the time of compillation, instead of at startup time. This commit moves the age calculation into the Base.banner() function, and moves the function from base/client.jl to base/version.jl in order to have access to the right variables.
1 parent 6891758 commit c629eb2

File tree

2 files changed

+48
-44
lines changed

2 files changed

+48
-44
lines changed

base/client.jl

-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ function input_color()
3131
return get(text_colors, c, default_color_input)
3232
end
3333

34-
banner() = print(have_color ? banner_color : banner_plain)
35-
3634
exit(n) = ccall(:jl_exit, Void, (Int32,), n)
3735
exit() = exit(0)
3836
quit() = exit()

base/version.jl

+48-42
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ end
180180

181181
## julia version info
182182

183-
begin
184183
# Include build number if we've got at least some distance from a tag (e.g. a release)
185184
build_number = BUILD_INFO.build_number != 0 ? "+$(BUILD_INFO.build_number)" : ""
186185
try
@@ -190,47 +189,54 @@ catch e
190189
global const VERSION = VersionNumber(0)
191190
end
192191

193-
if BUILD_INFO.tagged_commit
194-
const commit_string = BUILD_INFO.TAGGED_RELEASE_BANNER
195-
elseif BUILD_INFO.commit == ""
196-
const commit_string = ""
197-
else
198-
local days = int(floor((ccall(:clock_now, Float64, ()) - BUILD_INFO.fork_master_timestamp) / (60 * 60 * 24)))
199-
if BUILD_INFO.fork_master_distance == 0
200-
const commit_string = "Commit $(BUILD_INFO.commit_short) ($(days) days old master)"
192+
function banner()
193+
if BUILD_INFO.tagged_commit
194+
const commit_string = BUILD_INFO.TAGGED_RELEASE_BANNER
195+
elseif BUILD_INFO.commit == ""
196+
const commit_string = ""
201197
else
202-
const commit_string = "$(BUILD_INFO.branch)/$(BUILD_INFO.commit_short) (fork: $(BUILD_INFO.fork_master_distance) commits, $(days) days)"
198+
local days = int(floor((ccall(:clock_now, Float64, ()) - BUILD_INFO.fork_master_timestamp) / (60 * 60 * 24)))
199+
if BUILD_INFO.fork_master_distance == 0
200+
const commit_string = "Commit $(BUILD_INFO.commit_short) ($(days) days old master)"
201+
else
202+
const commit_string = "$(BUILD_INFO.branch)/$(BUILD_INFO.commit_short) (fork: $(BUILD_INFO.fork_master_distance) commits, $(days) days)"
203+
end
204+
end
205+
commit_date = BUILD_INFO.date_string != "" ? " ($(BUILD_INFO.date_string))": ""
206+
207+
const banner_plain =
208+
"""
209+
_
210+
_ _ _(_)_ | A fresh approach to technical computing
211+
(_) | (_) (_) | Documentation: http://docs.julialang.org
212+
_ _ _| |_ __ _ | Type \"help()\" to list help topics
213+
| | | | | | |/ _` | |
214+
| | |_| | | | (_| | | Version $(VERSION)$(commit_date)
215+
_/ |\\__'_|_|_|\\__'_| | $(commit_string)
216+
|__/ | $(Sys.MACHINE)
217+
218+
"""
219+
local tx = "\033[0m\033[1m" # text
220+
local jl = "\033[0m\033[1m" # julia
221+
local d1 = "\033[34m" # first dot
222+
local d2 = "\033[31m" # second dot
223+
local d3 = "\033[32m" # third dot
224+
local d4 = "\033[35m" # fourth dot
225+
const banner_color =
226+
"""\033[1m $(d3)_
227+
$(d1)_ $(jl)_$(tx) $(d2)_$(d3)(_)$(d4)_$(tx) | A fresh approach to technical computing
228+
$(d1)(_)$(jl) | $(d2)(_)$(tx) $(d4)(_)$(tx) | Documentation: http://docs.julialang.org
229+
$(jl)_ _ _| |_ __ _$(tx) | Type \"help()\" to list help topics
230+
$(jl)| | | | | | |/ _` |$(tx) |
231+
$(jl)| | |_| | | | (_| |$(tx) | Version $(VERSION)$(commit_date)
232+
$(jl)_/ |\\__'_|_|_|\\__'_|$(tx) | $(commit_string)
233+
$(jl)|__/$(tx) | $(Sys.MACHINE)
234+
235+
\033[0m"""
236+
237+
if have_color
238+
print(banner_color)
239+
else
240+
print(banner_plain)
203241
end
204242
end
205-
commit_date = BUILD_INFO.date_string != "" ? " ($(BUILD_INFO.date_string))": ""
206-
207-
const banner_plain =
208-
"""
209-
_
210-
_ _ _(_)_ | A fresh approach to technical computing
211-
(_) | (_) (_) | Documentation: http://docs.julialang.org
212-
_ _ _| |_ __ _ | Type \"help()\" to list help topics
213-
| | | | | | |/ _` | |
214-
| | |_| | | | (_| | | Version $(VERSION)$(commit_date)
215-
_/ |\\__'_|_|_|\\__'_| | $(commit_string)
216-
|__/ | $(Sys.MACHINE)
217-
218-
"""
219-
local tx = "\033[0m\033[1m" # text
220-
local jl = "\033[0m\033[1m" # julia
221-
local d1 = "\033[34m" # first dot
222-
local d2 = "\033[31m" # second dot
223-
local d3 = "\033[32m" # third dot
224-
local d4 = "\033[35m" # fourth dot
225-
const banner_color =
226-
"\033[1m $(d3)_
227-
$(d1)_ $(jl)_$(tx) $(d2)_$(d3)(_)$(d4)_$(tx) | A fresh approach to technical computing
228-
$(d1)(_)$(jl) | $(d2)(_)$(tx) $(d4)(_)$(tx) | Documentation: http://docs.julialang.org
229-
$(jl)_ _ _| |_ __ _$(tx) | Type \"help()\" to list help topics
230-
$(jl)| | | | | | |/ _` |$(tx) |
231-
$(jl)| | |_| | | | (_| |$(tx) | Version $(VERSION)$(commit_date)
232-
$(jl)_/ |\\__'_|_|_|\\__'_|$(tx) | $(commit_string)
233-
$(jl)|__/$(tx) | $(Sys.MACHINE)
234-
235-
\033[0m"
236-
end # begin

0 commit comments

Comments
 (0)