This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch main in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=a1dbea102e25d30337b75669896273232818a897 commit a1dbea102e25d30337b75669896273232818a897 Author: Guillem Jover <[email protected]> AuthorDate: Wed Mar 16 01:19:43 2022 +0100 Dpkg::Source::Package::V3::Git: Set origin remote to Vcs-Git if present If the packaging contains a Vcs-Git field, set it as the origin remote, to make the source easier to handle. --- scripts/Dpkg/Source/Package/V3/Git.pm | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/scripts/Dpkg/Source/Package/V3/Git.pm b/scripts/Dpkg/Source/Package/V3/Git.pm index 7f4be3f54..43f495afd 100644 --- a/scripts/Dpkg/Source/Package/V3/Git.pm +++ b/scripts/Dpkg/Source/Package/V3/Git.pm @@ -68,6 +68,17 @@ sub _sanity_check { return 1; } +sub _parse_vcs_git { + my $vcs_git = shift; + my ($url, $opt, $branch) = split ' ', $vcs_git; + + if (defined $opt && $opt eq '-b' && defined $branch) { + return ($url, $branch); + } else { + return ($url); + } +} + my @module_cmdline = ( { name => '--git-ref=<ref>', @@ -252,6 +263,18 @@ sub do_extract { } _sanity_check($newdirectory); + + if (defined $fields->{'Vcs-Git'}) { + my $remote = 'origin'; + my ($url, $head) = _parse_vcs_git($fields->{'Vcs-Git'}); + + my @git_remote_add = (qw(git -C), $newdirectory, qw(remote add)); + push @git_remote_add, '-m', $head if defined $head; + + info(g_('setting remote %s to %s'), $remote, $url); + system(@git_remote_add, $remote, $url); + subprocerr('git remote add') if $?; + } } 1; -- Dpkg.Org's dpkg

