Repository: JuliaLang/julia
File: stdlib/REPL/src/REPL.jl (Julia)

Code before:
input_color(r::StreamREPL) = r.input_color

# heuristic function to decide if the presence of a semicolon
# at the end of the expression was intended for suppressing output
function ends_with_semicolon(code)
    semi = false
    for tok in tokenize(code)
        kind(tok) in KSet"Whitespace NewlineWs Comment EndMarker" && continue
        semi = kind(tok) == K";"
    end
    return semi
end

"""
    banner(io::IO = stdout, preferred::Symbol = :full)

Print the "Julia" informative banner to `io`, using the `preferred` variant
if reasonable and known.

!!! warning
    The particular banner selected by `preferred` is liable to being changed
    without warning. The current variants are: `:tiny`, `:short`, `:narrow`, and `:full`.
"""
function banner(io::IO = stdout, preferred::Symbol = :full)
    commit_string = if Base.GIT_VERSION_INFO.tagged_commit
        Base.AnnotatedString(TAGGED_RELEASE_BANNER, :face => :shadow)
    elseif isempty(Base.GIT_VERSION_INFO.commit)
         styled""
    else
        days = Int(floor((ccall(:jl_clock_now, Float64, ()) - Base.GIT_VERSION_INFO.fork_master_timestamp) / (60 * 60 * 24)))
        days = max(0, days)
        unit = days == 1 ? "day" : "days"
        distance = Base.GIT_VERSION_INFO.fork_master_distance
        commit = Base.GIT_VERSION_INFO.commit_short

        if distance == 0
            styled"""Commit {grey:$commit} \
                     ({warning:⌛ {italic:$days $unit}} old master)"""
        else
            branch = Base.GIT_VERSION_INFO.branch
            styled"""{emphasis:$branch}/{grey:$commit} \
                     ({italic:{success:{bold,(slant=normal):↑} $distance commits}, \
                     {warning:{(slant=normal):⌛} $days $unit}})"""
        end
    end

    commit_date = isempty(Base.GIT_VERSION_INFO.date_string) ? "" : styled" {light:($(split(Base.GIT_VERSION_INFO.date_string)[1]))}"
    doclink = styled"{bold:Documentation:} {(underline=grey),link={https://docs.julialang.org}:https://docs.julialang.org}"
    help = styled"Type {repl_prompt_help:?} for help, {repl_prompt_pkg:]?} for {(underline=grey),link={https://pkgdocs.julialang.org/}:Pkg} help."

    sizenames = (:tiny, :short, :narrow, :full)

Review comment (bug):
The specific failure that was getting swallowed and turned into a deadlock was this (courtesy of @xal-0):
```
Unhandled Task ERROR: UndefVarError: `TAGGED_RELEASE_BANNER` not defined in `REPL`
Suggestion: check for spelling errors or missing imports.
Stacktrace:
 [1] banner(io::IO, preferred::Symbol)
   @ REPL ~/c/julia-1.13/usr/share/julia/stdlib/v1.13/REPL/src/REPL.jl:1719
 [2] run_std_repl(REPL::Module, quiet::Bool, banner::Symbol, history_file::Bool)
   @ Base ./client.jl:487
 [3] (::REPL.Precompile.var"#repl_workload##11#repl_workload##12"{Base.TTY, Base.TTY, Base.TTY})()
   @ REPL.Precompile ~/c/julia-1.13/usr/share/julia/stdlib/v1.13/REPL/src/precompile.jl:144
```
So this code path requires a tag in order to be exercised and thus observe the failure.

Code after:
input_color(r::StreamREPL) = r.input_color

# heuristic function to decide if the presence of a semicolon
# at the end of the expression was intended for suppressing output
function ends_with_semicolon(code)
    semi = false
    for tok in tokenize(code)
        kind(tok) in KSet"Whitespace NewlineWs Comment EndMarker" && continue
        semi = kind(tok) == K";"
    end
    return semi
end

function banner(io::IO = stdout; short = false)
    if Base.GIT_VERSION_INFO.tagged_commit
        commit_string = Base.TAGGED_RELEASE_BANNER
    elseif isempty(Base.GIT_VERSION_INFO.commit)
        commit_string = ""
    else
        days = Int(floor((ccall(:jl_clock_now, Float64, ()) - Base.GIT_VERSION_INFO.fork_master_timestamp) / (60 * 60 * 24)))
        days = max(0, days)
        unit = days == 1 ? "day" : "days"
        distance = Base.GIT_VERSION_INFO.fork_master_distance
        commit = Base.GIT_VERSION_INFO.commit_short

        if distance == 0
            commit_string = "Commit $(commit) ($(days) $(unit) old master)"
        else
            branch = Base.GIT_VERSION_INFO.branch
            commit_string = "$(branch)/$(commit) (fork: $(distance) commits, $(days) $(unit))"
        end
    end

    commit_date = isempty(Base.GIT_VERSION_INFO.date_string) ? "" : " ($(split(Base.GIT_VERSION_INFO.date_string)[1]))"

    if get(io, :color, false)::Bool
        c = Base.text_colors
        tx = c[:normal] # text
        jl = c[:normal] # julia
        d1 = c[:bold] * c[:blue]    # first dot
        d2 = c[:bold] * c[:red]     # second dot
        d3 = c[:bold] * c[:green]   # third dot
        d4 = c[:bold] * c[:magenta] # fourth dot

        if short
            print(io,"""
              $(d3)o$(tx)  | Version $(VERSION)$(commit_date)
             $(d2)o$(tx) $(d4)o$(tx) | $(commit_string)
            """)
        else
            print(io,"""               $(d3)_$(tx)