diff options
author | Robin H. Johnson <robbat2@gentoo.org> | 2024-03-13 22:16:07 -0700 |
---|---|---|
committer | Robin H. Johnson <robbat2@gentoo.org> | 2024-03-13 22:16:07 -0700 |
commit | accee68459a9bb3c289308669d596d2d9d31ae84 (patch) | |
tree | ead0b5aec26a1af798e1c2f863caa557aa336245 | |
parent | fix: skip empty metadata (diff) | |
download | gitolite-gentoo-nosync-quiet.tar.gz gitolite-gentoo-nosync-quiet.tar.bz2 gitolite-gentoo-nosync-quiet.zip |
feat: Mirroring support for quiet manual mirrornosync-quiet
Add copies type `nosync-quiet`, that offers nosync behavior without
triggering the warning on every push. Useful to manually sync a mirror
at specific times while not impacting regular work.
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
-rw-r--r-- | src/lib/Gitolite/Triggers/Mirroring.pm | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/lib/Gitolite/Triggers/Mirroring.pm b/src/lib/Gitolite/Triggers/Mirroring.pm index 07b7f96..dd33354 100644 --- a/src/lib/Gitolite/Triggers/Mirroring.pm +++ b/src/lib/Gitolite/Triggers/Mirroring.pm @@ -194,15 +194,16 @@ sub post_git { sub copies { my $repo = shift; + my %out; my $ref = git_config( $repo, "^gitolite-options\\.mirror\\.copies.*" ); - my %out = map { $_ => 'async' } map { split } values %$ref; + map { $out{$_} = 'async' } map { split } values %$ref; - $ref = git_config( $repo, "^gitolite-options\\.mirror\\.copies\\.sync.*" ); - map { $out{$_} = 'sync' } map { split } values %$ref; - - $ref = git_config( $repo, "^gitolite-options\\.mirror\\.copies\\.nosync.*" ); - map { $out{$_} = 'nosync' } map { split } values %$ref; + my @sync_types = qw(sync async nosync nosync-quiet); + foreach my $sync_type ( @sync_types ) { + $ref = git_config( $repo, "^gitolite-options\\.mirror\\.copies\\.${sync_type}.*" ); + map { $out{$_} = $sync_type } map { split } values %$ref; + } return %out; } @@ -237,9 +238,14 @@ sub push_to_copies { my $lb = "$ENV{GL_REPO_BASE}/$repo.git/.gl-mirror-lock"; for my $s ( sort keys %copies ) { trace( 1, "push_to_copies skipping self" ), next if $s eq $hn; - system("gitolite 1plus1 $lb.$s gitolite mirror push $s $repo </dev/null >/dev/null 2>&1 &") if $copies{$s} eq 'async'; - system("gitolite 1plus1 $lb.$s gitolite mirror push $s $repo </dev/null >/dev/null 2>&1") if $copies{$s} eq 'sync'; - _warn "manual mirror push pending for '$s'" if $copies{$s} eq 'nosync'; + my $mirror_command = "gitolite 1plus1 $lb.$s gitolite mirror push $s $repo </dev/null >/dev/null 2>&1"; + switch($copies{$s}) { + case 'async' { system($mirror_command . " &"); } + case 'sync' { system($mirror_command); } + case 'nosync' { _warn "manual mirror push pending for '$s'"; } + case 'nosync-quiet' { 1; } + else { _warn "unknown mirror copy type $copies{$s} for '$s'"; } + } } $ENV{GL_USER} = $u; |