v/cmd/tools/vup.v

56 lines
952 B
V
Raw Normal View History

2019-12-23 11:22:06 +01:00
module main
2019-12-23 11:09:22 +01:00
import (
os
2020-02-20 17:41:55 +01:00
v.pref
2020-04-14 03:32:32 +02:00
v.util
2019-12-23 11:09:22 +01:00
)
fn main() {
2020-03-07 22:26:26 +01:00
vroot := os.dir(pref.vexe_path())
os.chdir(vroot)
println('Updating V...')
2020-02-20 17:41:55 +01:00
// git pull
git_result := os.exec('git pull --rebase origin master') or {
2020-02-20 17:41:55 +01:00
panic(err)
}
if git_result.exit_code != 0 {
if git_result.output.contains('Permission denied') {
eprintln('have no access $vroot: Permission denied')
} else {
eprintln(git_result.output)
}
exit(1)
}
println(git_result.output)
2020-04-14 03:32:32 +02:00
v_hash := util.githash(false)
current_hash := util.githash(true)
// println(v_hash)
// println(current_hash)
if v_hash == current_hash {
return
}
2020-02-20 17:41:55 +01:00
$if windows {
2020-02-20 17:41:55 +01:00
v_backup_file := 'v_old.exe'
if os.exists(v_backup_file) {
os.rm(v_backup_file)
}
os.mv('v.exe', v_backup_file)
2020-03-07 22:26:26 +01:00
make_result := os.exec('make.bat') or {
2020-02-20 17:41:55 +01:00
panic(err)
}
println(make_result.output)
} $else {
make_result := os.exec('make') or {
2020-02-20 17:41:55 +01:00
panic(err)
}
println(make_result.output)
}
}