mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
vpm: check for git version before adding --also-filter-submodules
flag (#21259)
This commit is contained in:
parent
b44361344a
commit
423c39ccb4
1 changed files with 33 additions and 18 deletions
|
@ -1,6 +1,7 @@
|
||||||
module main
|
module main
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import semver
|
||||||
|
|
||||||
// Supported version control system commands.
|
// Supported version control system commands.
|
||||||
enum VCS {
|
enum VCS {
|
||||||
|
@ -19,25 +20,39 @@ struct VCSInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const vcs_info = {
|
const vcs_info = init_vcs_info() or {
|
||||||
VCS.git: VCSInfo{
|
vpm_error(err.msg())
|
||||||
dir: '.git'
|
exit(1)
|
||||||
args: struct {
|
}
|
||||||
install: 'clone --depth=1 --recursive --shallow-submodules --filter=blob:none --also-filter-submodules'
|
|
||||||
version: '--single-branch -b'
|
fn init_vcs_info() !map[VCS]VCSInfo {
|
||||||
update: 'pull --recurse-submodules' // pulling with `--depth=1` leads to conflicts when the upstream has more than 1 new commits.
|
git_installed_raw_ver := os.execute_opt('git --version')!.output.all_after_last(' ').all_before('.windows').trim_space()
|
||||||
path: '-C'
|
git_installed_ver := semver.from(git_installed_raw_ver)!
|
||||||
outdated: ['fetch', 'rev-parse @', 'rev-parse @{u}']
|
git_submod_filter_ver := semver.from('2.36.0')!
|
||||||
}
|
mut git_install_cmd := 'clone --depth=1 --recursive --shallow-submodules --filter=blob:none'
|
||||||
|
if git_installed_ver >= git_submod_filter_ver {
|
||||||
|
git_install_cmd += ' --also-filter-submodules'
|
||||||
}
|
}
|
||||||
VCS.hg: VCSInfo{
|
return {
|
||||||
dir: '.hg'
|
VCS.git: VCSInfo{
|
||||||
args: struct {
|
dir: '.git'
|
||||||
install: 'clone'
|
args: struct {
|
||||||
version: '--rev'
|
install: git_install_cmd
|
||||||
update: 'pull --update'
|
version: '--single-branch -b'
|
||||||
path: '-R'
|
update: 'pull --recurse-submodules' // pulling with `--depth=1` leads to conflicts when the upstream has more than 1 new commits.
|
||||||
outdated: ['incoming']
|
path: '-C'
|
||||||
|
outdated: ['fetch', 'rev-parse @', 'rev-parse @{u}']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
VCS.hg: VCSInfo{
|
||||||
|
dir: '.hg'
|
||||||
|
args: struct {
|
||||||
|
install: 'clone'
|
||||||
|
version: '--rev'
|
||||||
|
update: 'pull --update'
|
||||||
|
path: '-R'
|
||||||
|
outdated: ['incoming']
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue