...
This commit is contained in:
@@ -36,11 +36,10 @@ pub fn play(args_ PlayArgs) ! {
|
|||||||
url: url
|
url: url
|
||||||
sshkey: sshkey
|
sshkey: sshkey
|
||||||
recursive: recursive
|
recursive: recursive
|
||||||
|
light: light
|
||||||
}
|
}
|
||||||
if coderoot.len > 0 {
|
if coderoot.len > 0 {
|
||||||
gs = gittools.new(coderoot: coderoot, light: light)!
|
gs = gittools.new(coderoot: coderoot)!
|
||||||
} else {
|
|
||||||
gs.config_!.light = light // Update light setting on existing gs
|
|
||||||
}
|
}
|
||||||
gs.clone(clone_args)!
|
gs.clone(clone_args)!
|
||||||
}
|
}
|
||||||
@@ -49,47 +48,92 @@ pub fn play(args_ PlayArgs) ! {
|
|||||||
repo_actions := plbook.find(filter: 'git.repo_action')!
|
repo_actions := plbook.find(filter: 'git.repo_action')!
|
||||||
for action in repo_actions {
|
for action in repo_actions {
|
||||||
mut p := action.params
|
mut p := action.params
|
||||||
name := p.get('name')!
|
filter_str := p.get_default('filter', '')!
|
||||||
account := p.get('account')!
|
name := p.get_default('name', '')!
|
||||||
provider := p.get('provider')!
|
account := p.get_default('account', '')!
|
||||||
|
provider := p.get_default('provider', '')!
|
||||||
action_type := p.get('action')!
|
action_type := p.get('action')!
|
||||||
message := p.get_default('message', '')!
|
message := p.get_default('message', '')!
|
||||||
branchname := p.get_default('branchname', '')!
|
branchname := p.get_default('branchname', '')!
|
||||||
tagname := p.get_default('tagname', '')!
|
tagname := p.get_default('tagname', '')!
|
||||||
submodules := p.get_default_false('submodules')
|
submodules := p.get_default_false('submodules')
|
||||||
|
error_ignore := p.get_default_false('error_ignore')
|
||||||
|
|
||||||
mut repo := gs.get_repo(name: name, account: account, provider: provider)!
|
mut repos := gs.get_repos(
|
||||||
|
filter: filter_str
|
||||||
|
name: name
|
||||||
|
account: account
|
||||||
|
provider: provider
|
||||||
|
)!
|
||||||
|
|
||||||
match action_type {
|
if repos.len == 0 {
|
||||||
'pull' {
|
if !error_ignore {
|
||||||
repo.pull(submodules: submodules)!
|
return error('No repositories found for git.repo_action with filter: ${filter_str}, name: ${name}, account: ${account}, provider: ${provider}')
|
||||||
}
|
}
|
||||||
'commit' {
|
console.print_stderr('No repositories found for git.repo_action with filter: ${filter_str}, name: ${name}, account: ${account}, provider: ${provider}. Ignoring due to error_ignore: true.')
|
||||||
repo.commit(message)!
|
continue
|
||||||
}
|
}
|
||||||
'push' {
|
|
||||||
repo.push()!
|
for mut repo in repos {
|
||||||
}
|
match action_type {
|
||||||
'reset' {
|
'pull' {
|
||||||
repo.reset()!
|
repo.pull(submodules: submodules) or {
|
||||||
}
|
if !error_ignore { return error('Failed to pull repo ${repo.name}: ${err}') }
|
||||||
'branch_create' {
|
console.print_stderr('Failed to pull repo ${repo.name}: ${err}. Ignoring due to error_ignore: true.')
|
||||||
repo.branch_create(branchname)!
|
}
|
||||||
}
|
}
|
||||||
'branch_switch' {
|
'commit' {
|
||||||
repo.branch_switch(branchname)!
|
repo.commit(message) or {
|
||||||
}
|
if !error_ignore { return error('Failed to commit repo ${repo.name}: ${err}') }
|
||||||
'tag_create' {
|
console.print_stderr('Failed to commit repo ${repo.name}: ${err}. Ignoring due to error_ignore: true.')
|
||||||
repo.tag_create(tagname)!
|
}
|
||||||
}
|
}
|
||||||
'tag_switch' {
|
'push' {
|
||||||
repo.tag_switch(tagname)!
|
repo.push() or {
|
||||||
}
|
if !error_ignore { return error('Failed to push repo ${repo.name}: ${err}') }
|
||||||
'delete' {
|
console.print_stderr('Failed to push repo ${repo.name}: ${err}. Ignoring due to error_ignore: true.')
|
||||||
repo.delete()!
|
}
|
||||||
}
|
}
|
||||||
else {
|
'reset' {
|
||||||
return error('Unknown git.repo_action: ${action_type}')
|
repo.reset() or {
|
||||||
|
if !error_ignore { return error('Failed to reset repo ${repo.name}: ${err}') }
|
||||||
|
console.print_stderr('Failed to reset repo ${repo.name}: ${err}. Ignoring due to error_ignore: true.')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
'branch_create' {
|
||||||
|
repo.branch_create(branchname) or {
|
||||||
|
if !error_ignore { return error('Failed to create branch ${branchname} in repo ${repo.name}: ${err}') }
|
||||||
|
console.print_stderr('Failed to create branch ${branchname} in repo ${repo.name}: ${err}. Ignoring due to error_ignore: true.')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
'branch_switch' {
|
||||||
|
repo.branch_switch(branchname) or {
|
||||||
|
if !error_ignore { return error('Failed to switch branch to ${branchname} in repo ${repo.name}: ${err}') }
|
||||||
|
console.print_stderr('Failed to switch branch to ${branchname} in repo ${repo.name}: ${err}. Ignoring due to error_ignore: true.')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
'tag_create' {
|
||||||
|
repo.tag_create(tagname) or {
|
||||||
|
if !error_ignore { return error('Failed to create tag ${tagname} in repo ${repo.name}: ${err}') }
|
||||||
|
console.print_stderr('Failed to create tag ${tagname} in repo ${repo.name}: ${err}. Ignoring due to error_ignore: true.')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
'tag_switch' {
|
||||||
|
repo.tag_switch(tagname) or {
|
||||||
|
if !error_ignore { return error('Failed to switch tag to ${tagname} in repo ${repo.name}: ${err}') }
|
||||||
|
console.print_stderr('Failed to switch tag to ${tagname} in repo ${repo.name}: ${err}. Ignoring due to error_ignore: true.')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
'delete' {
|
||||||
|
repo.delete() or {
|
||||||
|
if !error_ignore { return error('Failed to delete repo ${repo.name}: ${err}') }
|
||||||
|
console.print_stderr('Failed to delete repo ${repo.name}: ${err}. Ignoring due to error_ignore: true.')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if !error_ignore { return error('Unknown git.repo_action: ${action_type}') }
|
||||||
|
console.print_stderr('Unknown git.repo_action: ${action_type}. Ignoring due to error_ignore: true.')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ pub mut:
|
|||||||
url string
|
url string
|
||||||
sshkey string
|
sshkey string
|
||||||
recursive bool // If true, also clone submodules
|
recursive bool // If true, also clone submodules
|
||||||
|
light bool // If true, clones only the last history for all branches (clone with only 1 level deep)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clones a new repository into the git structure based on the provided arguments.
|
// Clones a new repository into the git structure based on the provided arguments.
|
||||||
@@ -38,10 +39,8 @@ pub fn (mut gitstructure GitStructure) clone(args GitCloneArgs) !&GitRepo {
|
|||||||
|
|
||||||
parent_dir := repo.get_parent_dir(create: true)!
|
parent_dir := repo.get_parent_dir(create: true)!
|
||||||
|
|
||||||
cfg := gitstructure.config()!
|
|
||||||
|
|
||||||
mut extra := ''
|
mut extra := ''
|
||||||
if cfg.light {
|
if args.light {
|
||||||
extra = '--depth 1 --no-single-branch '
|
extra = '--depth 1 --no-single-branch '
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user