API-GitForge
view release on metacpan or search on metacpan
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
bin/git-clean-forge-fork view on Meta::CPAN
=back
=head1 FILES
=over 4
=item $XDG_CONFIG_HOME/.config/gitforge/access_tokens/I<DOMAIN>
Where I<DOMAIN> is the domain name of the git forge
(e.g. "github.com", "salsa.debian.org"), this file should contain an
API access token to log in to your account at the git forge. If
unset, $XDG_CONFIG_HOME defaults to ~/.config.
=back
=head1 SEE ALSO
git-nuke-forge-fork(1), git-clean-forge-repo(1)
=head1 AUTHOR
bin/git-clean-forge-repo view on Meta::CPAN
=back
=head1 FILES
=over 4
=item $XDG_CONFIG_HOME/.config/gitforge/access_tokens/I<DOMAIN>
Where I<DOMAIN> is the domain name of the git forge
(e.g. "github.com", "salsa.debian.org"), this file should contain an
API access token to log in to your account at the git forge. If
unset, $XDG_CONFIG_HOME defaults to ~/.config.
=back
=head1 SEE ALSO
git-clean-forge-fork(1)
=head1 AUTHOR
bin/git-nuke-forge-fork view on Meta::CPAN
=back
=head1 FILES
=over 4
=item $XDG_CONFIG_HOME/.config/gitforge/access_tokens/I<DOMAIN>
Where I<DOMAIN> is the domain name of the git forge
(e.g. "github.com", "salsa.debian.org"), this file should contain an
API access token to log in to your account at the git forge. If
unset, $XDG_CONFIG_HOME defaults to ~/.config.
=back
=head1 SEE ALSO
git-clean-forge-fork(1)
=head1 AUTHOR
lib/API/GitForge/GitHub.pm view on Meta::CPAN
$opts{access_token} = $self->{_access_token}
if exists $self->{_access_token};
$self->{_api} = Net::GitHub->new(%opts);
}
sub _ensure_fork {
my ($self, $upstream) = @_;
my ($org, $repo) = _extract_repo($upstream);
my $repos = $self->{_api}->repos;
my $user = $self->{_api}->user->show->{login};
my @user_repos = $repos->list_user($user);
my $repo_exists = sub {
grep { $_->{name} eq $repo } @user_repos;
};
if (&$repo_exists) {
$self->_assert_fork_has_parent($upstream);
} else {
$repos->create_fork($org, $repo);
until (&$repo_exists) {
sleep 5;
@user_repos = $repos->list_user($user);
}
}
return "https://github.com/$user/$repo";
}
sub _assert_fork_has_parent {
my ($self, $upstream) = @_;
my (undef, $repo) = _extract_repo($upstream);
my $user = $self->{_api}->user->show->{login};
my $fork = $self->{_api}->repos->get($user, $repo);
$fork->{parent}{full_name} eq $upstream
or croak
"$user/$repo does not have parent $upstream; don't know what to do";
}
sub _clean_config_repo {
my ($self, $target) = @_;
my ($org, $repo) = _extract_repo($target);
lib/API/GitForge/GitHub.pm view on Meta::CPAN
has_issues => 0,
has_downloads => 0,
has_pages => 0,
has_projects => 0,
});
}
sub _clean_config_fork {
my ($self, $upstream) = @_;
my (undef, $repo) = _extract_repo($upstream);
my $user = $self->{_api}->user->show->{login};
my $repos = $self->{_api}->repos;
$repos->set_default_user_repo($user, $repo);
$repos->update({
name => "$repo",
homepage => "",
description => "Temporary fork for pull request(s)",
default_branch => "gitforge",
});
$self->_clean_config_repo("$user/$repo");
}
sub _ensure_repo {
my ($self, $target) = @_;
my ($org, $repo) = _extract_repo($target);
my $repos = $self->{_api}->repos;
my $user = $self->{_api}->user->show->{login};
my %create_opts = (name => $repo);
my $list_method;
if ($org eq $user) {
$list_method = "list_user";
} else {
$list_method = "list_org";
$create_opts{org} = $org unless $org eq $user;
}
my @list_repos = $repos->$list_method($org);
my $repo_exists = sub {
lib/API/GitForge/GitHub.pm view on Meta::CPAN
@list_repos = $repos->$list_method($org);
}
}
return "https://github.com/$org/$repo";
}
sub _nuke_fork {
my ($self, $upstream) = @_;
$self->_assert_fork_has_parent($upstream);
my (undef, $repo) = _extract_repo($upstream);
my $user = $self->{_api}->user->show->{login};
$self->{_api}->repos->delete($user, $repo);
}
sub _extract_repo {
$_[0] =~ m#^([^/]+)/(.+)(?:\.git)?$#;
($1, $2);
}
1;
( run in 1.388 second using v1.01-cache-2.11-cpan-49f99fa48dc )