vup: make 'v up' work from release archive, without a .git folder
parent
3bbda7103f
commit
8c8df66986
|
@ -11,21 +11,18 @@ fn main() {
|
|||
|
||||
println('Updating V...')
|
||||
|
||||
// git pull
|
||||
git_result := os.exec('git pull --rebase origin master') or {
|
||||
panic(err)
|
||||
if !os.exists('.git') {
|
||||
// initialize as if it had been cloned
|
||||
git_command('init')
|
||||
git_command('remote add origin https://github.com/vlang/v')
|
||||
git_command('fetch')
|
||||
git_command('reset --hard origin/master')
|
||||
git_command('clean --quiet -xdf --exclude v.exe --exclude cmd/tools/vup.exe')
|
||||
} else {
|
||||
// pull latest
|
||||
git_command('pull origin master')
|
||||
}
|
||||
|
||||
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)
|
||||
v_hash := util.githash(false)
|
||||
current_hash := util.githash(true)
|
||||
// println(v_hash)
|
||||
|
@ -77,3 +74,21 @@ fn backup(file string) {
|
|||
}
|
||||
os.mv(file, backup_file)
|
||||
}
|
||||
|
||||
fn git_command(command string) {
|
||||
vexe := pref.vexe_path()
|
||||
vroot := os.dir(vexe)
|
||||
|
||||
git_result := os.exec('git $command') or {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue