#!/bin/sh # This file is a part of Julia. License is MIT: https://julialang.org/license # Needs to be run from a julia repo clone # First argument (optional) is a ref to the commit global gitref := $(1:-HEAD) global ver := $[git show "$gitref:VERSION] global major := $[echo $ver | cut -f 1 -d .] global minor := $[echo $ver | cut -f 2 -d .] if test $major = 0 -a $minor -lt 5 { # use tag based build number prior to 0.5.0- global last_tag := $[git describe --tags --abbrev=0 $gitref] global nb := $[git rev-list --count $gitref "^$last_tag] if test $nb = 0 { echo $ver } else { echo "$ver+$nb" } } else { global topdir := $[git rev-parse --show-toplevel] global verchanged := $[git blame -L ,1 -sl $gitref -- "$topdir/VERSION" | cut -f 1 -d " ] global nb := $[git rev-list --count $gitref "^$verchanged] global pre := $[echo $ver | cut -s -f 2 -d "-] if test $ver = "0.5.0-dev" { # bump to 0.5.0-dev was one commit after tag during 0.5.0-dev global nb := $[expr $nb + 1] } elif test $ver = "0.5.0-pre" { # bump to 0.5.0-pre was 5578 commits after tag global nb := $[expr $nb + 5578] } if test -n $pre { if test $major = 0 -a $minor -le 5 { echo "$ver+$nb" } else { echo "$ver.$nb" } } else { echo $ver } } (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:gitref) op: Equal rhs: { (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(HEAD)}) spids: [15 19] ) } spids: [14] ) ] spids: [14] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:ver) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [(C {(git)} {(show)} {(DQ ($ VSub_Name "$gitref") (":VERSION"))})] ) left_token: spids: [23 32] ) } spids: [22] ) ] spids: [22] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:major) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(echo)} {($ VSub_Name "$ver")}) (C {(cut)} {(-f)} {(1)} {(-d)} {(.)}) ] negated: False ) ] ) left_token: spids: [35 51] ) } spids: [34] ) ] spids: [34] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:minor) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(echo)} {($ VSub_Name "$ver")}) (C {(cut)} {(-f)} {(2)} {(-d)} {(.)}) ] negated: False ) ] ) left_token: spids: [54 70] ) } spids: [53] ) ] spids: [53] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {($ VSub_Name "$major")} {(Lit_Other "=")} {(0)} {(-a)} {($ VSub_Name "$minor")} {(-lt)} {(5)} {(Lit_Other "]")} ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:last_tag) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (C {(git)} {(describe)} {(--tags)} {(--abbrev) (Lit_Other "=") (0)} {(DQ ($ VSub_Name "$gitref"))} ) ] ) left_token: spids: [102 116] ) } spids: [101] ) ] spids: [101] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:nb) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (C {(git)} {(rev-list)} {(--count)} {(DQ ($ VSub_Name "$gitref"))} {(DQ ("^") ($ VSub_Name "$last_tag"))} ) ] ) left_token: spids: [120 135] ) } spids: [119] ) ] spids: [119] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {($ VSub_Name "$nb")} {(Lit_Other "=")} {(0)} {(Lit_Other "]")} ) terminator: ) ] action: [(C {(echo)} {($ VSub_Name "$ver")})] spids: [-1 151] ) ] else_action: [(C {(echo)} {(DQ ($ VSub_Name "$ver") ("+") ($ VSub_Name "$nb"))})] spids: [159 171] ) ] spids: [-1 94] ) ] else_action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:topdir) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [(C {(git)} {(rev-parse)} {(--show-toplevel)})] ) left_token: spids: [177 183] ) } spids: [176] ) ] spids: [176] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:verchanged) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(git)} {(blame)} {(-L)} {(Lit_Comma ",") (1)} {(-sl)} {($ VSub_Name "$gitref")} {(--)} {(DQ ($ VSub_Name "$topdir") (/VERSION))} ) (C {(cut)} {(-f)} {(1)} {(-d)} {(DQ (" "))}) ] negated: False ) ] ) left_token: spids: [187 221] ) } spids: [186] ) ] spids: [186] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:nb) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (C {(git)} {(rev-list)} {(--count)} {(DQ ($ VSub_Name "$gitref"))} {(DQ ("^") ($ VSub_Name "$verchanged"))} ) ] ) left_token: spids: [225 240] ) } spids: [224] ) ] spids: [224] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:pre) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(echo)} {($ VSub_Name "$ver")}) (C {(cut)} {(-s)} {(-f)} {(2)} {(-d)} {(DQ (-))}) ] negated: False ) ] ) left_token: spids: [244 264] ) } spids: [243] ) ] spids: [243] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {($ VSub_Name "$ver")} {(Lit_Other "=")} {(DQ (0.5.0-dev))} {(Lit_Other "]")} ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:nb) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [(C {(expr)} {($ VSub_Name "$nb")} {(Lit_Other "+")} {(1)})] ) left_token: spids: [290 298] ) } spids: [289] ) ] spids: [289] ) ] spids: [-1 282] ) (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {($ VSub_Name "$ver")} {(Lit_Other "=")} {(DQ (0.5.0-pre))} {(Lit_Other "]")} ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:nb) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (C {(expr)} {($ VSub_Name "$nb")} {(Lit_Other "+")} {(5578)}) ] ) left_token: spids: [324 332] ) } spids: [323] ) ] spids: [323] ) ] spids: [301 316] ) ] spids: [-1 335] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-n)} {(DQ ($ VSub_Name "$pre"))} {(Lit_Other "]")}) terminator: ) ] action: [ (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {($ VSub_Name "$major")} {(Lit_Other "=")} {(0)} {(-a)} {($ VSub_Name "$minor")} {(-le)} {(5)} {(Lit_Other "]")} ) terminator: ) ] action: [(C {(echo)} {(DQ ($ VSub_Name "$ver") ("+") ($ VSub_Name "$nb"))})] spids: [-1 375] ) ] else_action: [(C {(echo)} {(DQ ($ VSub_Name "$ver") (.) ($ VSub_Name "$nb"))})] spids: [387 399] ) ] spids: [-1 351] ) ] else_action: [(C {(echo)} {($ VSub_Name "$ver")})] spids: [402 410] ) ] spids: [173 412] ) ] )