From 81148fa2bdd85bce0bd871d99d0d4e96239c7ae8 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sat, 16 May 2020 23:52:03 +0200 Subject: [PATCH] cmd/v: version: print only main repo hash --- cmd/v/v.v | 18 +++++++++++------- vlib/v/util/util.v | 10 +++++++--- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/cmd/v/v.v b/cmd/v/v.v index 1c2561090e..81940103ad 100644 --- a/cmd/v/v.v +++ b/cmd/v/v.v @@ -37,18 +37,18 @@ fn main_v() { util.launch_tool(false, 'vrepl') return } + args_and_flags := util.join_env_vflags_and_os_args()[1..] + prefs, command := pref.parse_args(args_and_flags) + //if prefs.is_verbose { + //println('command = "$command"') + //println(util.full_v_version(prefs.is_verbose)) + //} if args.len > 0 && (args[0] in ['version', '-V', '-version', '--version'] || (args[0] == '-v' && args.len == 1)) { // `-v` flag is for setting verbosity, but without any args it prints the version, like Clang - println(util.full_v_version()) + println(util.full_v_version(prefs.is_verbose)) return } - args_and_flags := util.join_env_vflags_and_os_args()[1..] - prefs, command := pref.parse_args(args_and_flags) - if prefs.is_verbose { - println('command = "$command"') - println(util.full_v_version()) - } if prefs.is_verbose { // println('args= ') // println(args) // QTODO @@ -82,6 +82,10 @@ fn main_v() { println('V Error: Use `v install` to install modules from vpm.vlang.io') exit(1) } + 'version' { + println(util.full_v_version(prefs.is_verbose)) + return + } 'symlink' { create_symlink() return diff --git a/vlib/v/util/util.v b/vlib/v/util/util.v index 5392e068ff..68d3c382a6 100644 --- a/vlib/v/util/util.v +++ b/vlib/v/util/util.v @@ -33,8 +33,12 @@ pub fn full_hash() string { } // full_v_version() returns the full version of the V compiler -pub fn full_v_version() string { - return 'V ${v_version} ${full_hash()}' +pub fn full_v_version(is_verbose bool) string { + if is_verbose { + return 'V ${v_version} ${full_hash()}' + } + hash := githash(false) + return 'V ${v_version} $hash' } // githash(x) returns the current git commit hash. @@ -172,7 +176,7 @@ pub fn quote_path_with_spaces(s string) string { pub fn args_quote_paths_with_spaces(args []string) string { mut res := []string{} for a in args { - res << quote_path_with_spaces( a ) + res << quote_path_with_spaces(a) } return res.join(' ') }