Skip to content

Commit 37c3f65

Browse files
committed
v.util.version: centralise the use of @VCURRENTHASH, to minimise the vlang/vc diffs for each commit
1 parent dc222b6 commit 37c3f65

4 files changed

Lines changed: 16 additions & 9 deletions

File tree

‎vlib/builtin/builtin.c.v‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ fn panic_debug(line_no int, file string, mod string, fn_name string, s string) {
7171
eprint(' message: '); eprintln(s)
7272
eprint(' file: '); eprint(file); eprint(':');
7373
C.fprintf(C.stderr, c'%d\n', line_no)
74-
eprint(' v hash: '); eprintln(@VCURRENTHASH)
74+
eprint(' v hash: '); eprintln(vcurrent_hash())
7575
eprintln('=========================================')
7676
// vfmt on
7777
$if native {
@@ -117,6 +117,10 @@ pub fn panic_result_not_set(s string) {
117117
panic('result not set (' + s + ')')
118118
}
119119

120+
pub fn vcurrent_hash() string {
121+
return @VCURRENTHASH
122+
}
123+
120124
// panic prints a nice error message, then exits the process with exit code of 1.
121125
// It also shows a backtrace on most platforms.
122126
@[noreturn]
@@ -128,7 +132,7 @@ pub fn panic(s string) {
128132
eprint('V panic: ')
129133
eprintln(s)
130134
eprint('v hash: ')
131-
eprintln(@VCURRENTHASH)
135+
eprintln(vcurrent_hash())
132136
$if native {
133137
C.exit(1) // TODO: native backtraces
134138
} $else $if exit_after_panic_message ? {

‎vlib/v/checker/checker.v‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,11 @@ pub fn new_checker(table &ast.Table, pref_ &pref.Preferences) &Checker {
154154
$if time_checking ? {
155155
timers_should_print = true
156156
}
157+
v_current_commit_hash := if pref_.building_v {
158+
version.githash(pref_.vroot) or { vcurrent_hash() }
159+
} else {
160+
vcurrent_hash()
161+
}
157162
mut checker := &Checker{
158163
table: table
159164
pref: pref_
@@ -162,8 +167,7 @@ pub fn new_checker(table &ast.Table, pref_ &pref.Preferences) &Checker {
162167
label: 'checker'
163168
)
164169
match_exhaustive_cutoff_limit: pref_.checker_match_exhaustive_cutoff_limit
165-
v_current_commit_hash: if pref_.building_v { version.githash(pref_.vroot) or {
166-
@VCURRENTHASH} } else { @VCURRENTHASH }
170+
v_current_commit_hash: v_current_commit_hash
167171
}
168172
checker.type_resolver = type_resolver.TypeResolver.new(table, checker)
169173
checker.comptime = &checker.type_resolver.info

‎vlib/v/eval/eval.v‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ fn (e &Eval) error(msg string) {
289289

290290
fn (e &Eval) panic(s string) {
291291
eprintln('V panic: ${s}')
292-
eprintln('V hash: ${@VCURRENTHASH}')
292+
eprintln('V hash: ${vcurrent_hash()}')
293293
e.print_backtrace()
294294
exit(1)
295295
}

‎vlib/v/util/version/version.v‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,18 @@ pub const v_version = '0.4.9'
66

77
pub fn full_hash() string {
88
build_hash := vhash()
9-
current_hash := @VCURRENTHASH
10-
if build_hash == current_hash {
9+
if build_hash == vcurrent_hash() {
1110
return build_hash
1211
}
13-
return '${build_hash}.${current_hash}'
12+
return '${build_hash}.${vcurrent_hash()}'
1413
}
1514

1615
// full_v_version() returns the full version of the V compiler
1716
pub fn full_v_version(is_verbose bool) string {
1817
if is_verbose {
1918
return 'V ${v_version} ${full_hash()}'
2019
}
21-
return 'V ${v_version} ${@VCURRENTHASH}'
20+
return 'V ${v_version} ${vcurrent_hash()}'
2221
}
2322

2423
// githash tries to find the current git commit hash for the specified

0 commit comments

Comments
 (0)