From 6b8c6cc16d658e7d2a8de12250676087a8824220 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 26 Mar 2023 01:44:25 -0400 Subject: give up on gitlab --- modules/tozt/files/new-git-repo | 62 ----------------------------------------- modules/tozt/files/post-receive | 8 ------ modules/tozt/manifests/git.pp | 11 -------- 3 files changed, 81 deletions(-) diff --git a/modules/tozt/files/new-git-repo b/modules/tozt/files/new-git-repo index 43c619b..0803191 100755 --- a/modules/tozt/files/new-git-repo +++ b/modules/tozt/files/new-git-repo @@ -15,7 +15,6 @@ package NewGitRepo { sub new($class, %opts) { bless { github_user => $opts{github_user}, - gitlab_user => $opts{gitlab_user}, root => $opts{root}, }, $class; } @@ -23,9 +22,7 @@ package NewGitRepo { sub init($self, %opts) { my $new_dir = "${\$self->{root}}/$opts{name}"; my $github_user = $self->{github_user}; - my $gitlab_user = $self->{gitlab_user}; my $github_token = $self->github_token; - my $gitlab_token = $self->gitlab_token; local $ENV{GIT_DIR} = $new_dir; @@ -48,18 +45,11 @@ package NewGitRepo { $self->create_github_repository($opts{name}, $opts{description}); } - $self->create_gitlab_repository($opts{name}, $opts{description}); - git( 'remote', 'add', 'github', "https://$github_user:$github_token\@github.com/$github_user/$opts{name}", ); - git( - 'remote', - 'add', 'gitlab', - "https://$gitlab_user:$gitlab_token\@gitlab.com/$gitlab_user/$opts{name}.git", - ); my $cgitrc = $self->generate_cgitrc(%opts); spew("$new_dir/cgitrc", $cgitrc); @@ -130,20 +120,6 @@ EOF ); } - sub create_gitlab_repository($self, $name, $description) { - $self->gitlab_v4( - 'POST', - '/projects', - { - name => $name, - (defined($description) - ? (description => $description) - : ()), - visibility => 'public', - } - ); - } - sub github_v3($self, $method, $path, $data=undef) { my $res = $self->github_ua->request( $method, @@ -173,22 +149,6 @@ EOF decode_json($res->{content}) } - sub gitlab_v4($self, $method, $path, $data=undef) { - my $res = $self->gitlab_ua->request( - $method, - "https://gitlab.com/api/v4$path", - { - (defined($data) - ? (content => encode_json($data)) - : ()), - } - ); - if (!$res->{success}) { - die "query failed ($res->{status}): $res->{content}"; - } - decode_json($res->{content}) - } - sub github_ua($self) { $self->{github_ua} ||= HTTP::Tiny->new( default_headers => { @@ -200,17 +160,6 @@ EOF ); } - sub gitlab_ua($self) { - $self->{gitlab_ua} ||= HTTP::Tiny->new( - default_headers => { - 'Authorization' => "bearer ${\$self->gitlab_token}", - 'Content-Type' => "application/json", - 'Accept' => "application/json", - }, - verify_SSL => 1, - ); - } - sub github_token($self) { $self->{github_token} ||= do { chomp(my $token = slurp("$ENV{HOME}/.github")); @@ -218,13 +167,6 @@ EOF } } - sub gitlab_token($self) { - $self->{gitlab_token} ||= do { - chomp(my $token = slurp("$ENV{HOME}/.gitlab")); - $token - } - } - sub git(@args) { system('git', @args) and die "couldn't run git: $!"; } @@ -245,11 +187,9 @@ EOF sub main(@argv) { my %opts = parse_args(\@argv); my $github_user = delete $opts{github_user}; - my $gitlab_user = delete $opts{gitlab_user}; my $root = delete $opts{root}; NewGitRepo->new( github_user => $github_user, - gitlab_user => $gitlab_user, root => $root, )->init(%opts); } @@ -258,7 +198,6 @@ sub parse_args($argv) { my %opts = ( from_github => undef, github_user => "doy", - gitlab_user => "doyster", root => "$ENV{HOME}/git", unmaintained => undef, description => undef, @@ -268,7 +207,6 @@ sub parse_args($argv) { $argv, 'from-github' => \$opts{from_github}, 'github_user=s' => \$opts{github_user}, - 'gitlab_user=s' => \$opts{gitlab_user}, 'root=s' => \$opts{root}, 'unmaintained' => \$opts{unmaintained}, 'description=s' => \$opts{description}, diff --git a/modules/tozt/files/post-receive b/modules/tozt/files/post-receive index 9d909a4..2f26f7c 100755 --- a/modules/tozt/files/post-receive +++ b/modules/tozt/files/post-receive @@ -5,12 +5,4 @@ set -o pipefail mkdir -p info/web git for-each-ref --sort=committerdate --format='%(committerdate)' refs/heads | tail -n1 > info/web/last-modified -# XXX github accepts pushes of things under refs/remotes (and presumably just -# ignores them), but gitlab throws an error when you do this. as far as i can -# tell though, --mirror is the only way to keep the list of branches in sync -# (like, delete remote branches when the local branch is deleted, etc), and -# there's no way to configure the set of refs when using --mirror, so this is -# probably the best i can do for now -rm -rf refs/remotes -git push --mirror gitlab git push --mirror github diff --git a/modules/tozt/manifests/git.pp b/modules/tozt/manifests/git.pp index ab56f30..7e96417 100644 --- a/modules/tozt/manifests/git.pp +++ b/modules/tozt/manifests/git.pp @@ -75,17 +75,6 @@ class tozt::git { ]; } - secret { "/home/doy/.gitlab": - source => 'gitlab', - owner => 'doy', - group => 'doy', - require => [ - User['doy'], - Group['doy'], - File["/home/doy"], - ]; - } - nginx::site { "git-tls": source => 'puppet:///modules/tozt/nginx/git-tls.conf', -- cgit v1.2.3-54-g00ecf