v version: do more accurate current git hash detection, when not on a branch
parent
d33082dffe
commit
1bf13f8a09
|
@ -62,15 +62,19 @@ pub fn githash(should_get_from_filesystem bool) string {
|
||||||
head_content := os.read_file(git_head_file) or {
|
head_content := os.read_file(git_head_file) or {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
gcbranch_rel_path := head_content.replace('ref: ', '').trim_space()
|
mut current_branch_hash := head_content
|
||||||
gcbranch_file := os.join_path(vroot, '.git', gcbranch_rel_path)
|
if head_content.starts_with('ref: ') {
|
||||||
// .git/refs/heads/master
|
gcbranch_rel_path := head_content.replace('ref: ', '').trim_space()
|
||||||
if !os.exists(gcbranch_file) {
|
gcbranch_file := os.join_path(vroot, '.git', gcbranch_rel_path)
|
||||||
break
|
// .git/refs/heads/master
|
||||||
}
|
if !os.exists(gcbranch_file) {
|
||||||
// get the full commit hash contained in the ref heads file
|
break
|
||||||
current_branch_hash := os.read_file(gcbranch_file) or {
|
}
|
||||||
break
|
// get the full commit hash contained in the ref heads file
|
||||||
|
branch_hash := os.read_file(gcbranch_file) or {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
current_branch_hash = branch_hash
|
||||||
}
|
}
|
||||||
desired_hash_length := 7
|
desired_hash_length := 7
|
||||||
if current_branch_hash.len > desired_hash_length {
|
if current_branch_hash.len > desired_hash_length {
|
||||||
|
@ -112,9 +116,7 @@ pub fn launch_tool(is_verbose bool, tool_name string) {
|
||||||
mut should_compile := false
|
mut should_compile := false
|
||||||
if !os.exists(tool_exe) {
|
if !os.exists(tool_exe) {
|
||||||
should_compile = true
|
should_compile = true
|
||||||
}
|
} else {
|
||||||
//
|
|
||||||
else {
|
|
||||||
if os.file_last_mod_unix(tool_exe) <= os.file_last_mod_unix(vexe) {
|
if os.file_last_mod_unix(tool_exe) <= os.file_last_mod_unix(vexe) {
|
||||||
// v was recompiled, maybe after v up ...
|
// v was recompiled, maybe after v up ...
|
||||||
// rebuild the tool too just in case
|
// rebuild the tool too just in case
|
||||||
|
|
Loading…
Reference in New Issue