vpm outdated: add support for mercurial (#6376)

pull/6384/head
Lukas Neubert 2020-09-15 18:35:00 +02:00 committed by GitHub
parent 4b1e330219
commit 8b25c29323
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 8 deletions

View File

@ -1,3 +1,6 @@
// Copyright (c) 2019-2020 Alexander Medvednikov. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
module main module main
import os import os
@ -23,6 +26,7 @@ const (
} }
supported_vcs_outdated_steps = { supported_vcs_outdated_steps = {
'git': ['git fetch', 'git rev-parse @', 'git rev-parse @{u}'] 'git': ['git fetch', 'git rev-parse @', 'git rev-parse @{u}']
'hg': ['hg incoming']
} }
) )
@ -253,22 +257,23 @@ fn get_outdated() ?[]string {
vcs := vcs_used_in_dir(final_module_path) or { vcs := vcs_used_in_dir(final_module_path) or {
continue continue
} }
if vcs[0] != 'git' {
println('Check for $name was skipped.')
verbose_println('VCS ${vcs[0]} does ot support `v outdated`.')
continue
}
vcs_cmd_steps := supported_vcs_outdated_steps[vcs[0]] vcs_cmd_steps := supported_vcs_outdated_steps[vcs[0]]
mut outputs := []string{} mut outputs := []string{}
for step in vcs_cmd_steps { for step in vcs_cmd_steps {
res := os.exec(step) or { res := os.exec(step) or {
verbose_println('Error command: git fetch') verbose_println('Error command: $step')
verbose_println('Error details:\n$err') verbose_println('Error details:\n$err')
return error('Error while checking latest commits for "$name".') return error('Error while checking latest commits for "$name".')
} }
outputs << res.output if vcs[0] == 'hg' {
if res.exit_code == 1 {
outdated << name
}
} else {
outputs << res.output
}
} }
if outputs[1] != outputs[2] { if vcs[0] == 'git' && outputs[1] != outputs[2] {
outdated << name outdated << name
} }
} }