Hi,
On Tue, 2008-03-25 at 20:25 +0100, Luca Capello wrote:
> It seems I missed your last mail: I remember having read it and then I
> forgot, sorry.
No worries.
> On Sun, 23 Mar 2008 18:32:11 +0100, Adam D. Barratt wrote:
> > On Tue, 2007-10-23 at 21:21 +0200, Luca Capello wrote:
> >> At least for this particular case, i.e. the personal repositories on
> >> Alioth, when in authentication mode debcheckout should check if the
> >> repository belongs to the user specified with -u or the login one.
> >
> > Would the attached patch, based on your original darcs patch in #445714,
> > be sufficient, at least for git?
>
> Your patch should be OK, but I haven't tested it.
I've been playing with it a little more, and attached a revised patch.
This rewrites both git.d.o/git/users/foo/bar and git.d.o/~foo/bar to git
+ssh://[EMAIL PROTECTED]/~/public_git/bar (which afaics is the correct
rewrite).
It also contains a couple of other tweaks, which I'll commit separately:
- tightens the darcs regex so http://darcs.d.o/adam/foo/bar doesn't
claim not to be owned by user adam
- doesn't abort on a user mismatch if -p was passed
> However when it's
> possible I'd prefer a common solution. This is also the reason I tried
> to have darcs.d.o reconfigured in a way similar to git [1].
Consistency is always good but there doesn't appear to be anything
happening with that ticket :-/
I'm now monitoring the Alioth ticket so my proposal is that I commit the
patch as it stands and if the Alioth admins apply your suggestion then
we can revisit things then.
Regards,
Adam
--- scripts/debcheckout.pl 2008-03-24 01:13:43.000000000 +0000
+++ debcheckout.pl 2008-03-25 21:23:10.000000000 +0000
@@ -18,7 +18,7 @@
#
# Created: Tue, 14 Aug 2007 10:20:55 +0200
-# Last-Modified: $Date: 2008-03-24 01:13:42 +0000 (Mon, 24 Mar 2008) $
+# Last-Modified: $Date: 2008-03-22 21:47:34 +0000 (Sat, 22 Mar 2008) $
=head1 NAME
@@ -223,28 +223,39 @@
# Patch a given repository URL to ensure that the checkoud out repository can be
# committed to. Only works for well known repositories (mainly Alioth's).
-sub set_auth($$$) {
- my ($repo_type, $url, $user) = @_;
-
+sub set_auth($$$$) {
+ my ($repo_type, $url, $user, $print_only) = @_;
my $old_url = $url;
$user .= "@" if length $user;
+ my $user_local = $user;
+ $user_local =~ s|(.*)(@)|$1|;
+ my $user_url = $url;
switch ($repo_type) {
case "bzr" { $url =~ s|^\w+://(bzr\.debian\.org)/(.*)|sftp://$user$1/bzr/$2|;
$url =~ s[^\w+://(?:(bazaar|code)\.)?(launchpad\.net/.*)][bzr+ssh://${user}bazaar.$2];}
case "darcs" {
+ $user_url =~ s|^\w+://(darcs\.debian\.org)/(~)(.*?)/.*|$3|;
if ($url =~ m|(~)|) {
- my $user_local = $user;
- $user_local =~ s|(.*)(@)|$1|;
- my $user_url = $url;
- $user_url =~ s|^\w+://(darcs\.debian\.org)/(~)(.*)/.*|$3|;
die "the local user '$user_local' doesn't own the personal repository '$url'\n"
- if $user_local ne $user_url;
- $url =~ s|^\w+://(darcs\.debian\.org)/(~)(.*)/(.*)|$user$1:~/public_darcs/$4|;
+ if $user_local ne $user_url and !$print_only;
+ $url =~ s|^\w+://(darcs\.debian\.org)/(~)(.*?)/(.*)|$user$1:~/public_darcs/$4|;
} else {
$url =~ s|^\w+://(darcs\.debian\.org)/(.*)|$user$1:/darcs/$2|;
}
}
- case "git" { $url =~ s|^\w+://(git\.debian\.org/.*)|git+ssh://$user$1|; }
+ case "git" {
+ $user_url =~ s|^\w+://(git\.debian\.org)/git/users/(.*?)/.*|$2|;
+ $user_url =~ s|^\w+://(git\.debian\.org)/~(.*?)/.*|$2|;
+
+ if ($url =~ m%(/users/|~)%) {
+ die "the local user '$user_local' doesn't own the personal repository '$url'\n"
+ if $user_local ne $user_url and !$print_only;
+ $url =~ s|^\w+://(git\.debian\.org)/git/users/.*?/(.*)|git+ssh://$user$1/~/public_git/$2|;
+ $url =~ s|^\w+://(git\.debian\.org)/~.*?/(.*)|git+ssh://$user$1/~/public_git/$2|;
+ } else {
+ $url =~ s|^\w+://(git\.debian\.org/.*)|git+ssh://$user$1|;
+ }
+ }
case "hg" { $url =~ s|^\w+://(hg\.debian\.org/.*)|ssh://$user$1|; }
case "svn" { $url =~ s|^\w+://(svn\.debian\.org)/(.*)|svn+ssh://$user$1/svn/$2|; }
else { die "sorry, don't know how to enable authentication for $repo_type repositories (patches welcome!)\n"; }
@@ -564,7 +575,7 @@
$browse_url = find_browse($pkg) if @files;
}
- $repo_url = set_auth($repo_type, $repo_url, $user) if $auth and not @files;
+ $repo_url = set_auth($repo_type, $repo_url, $user, $print_only) if $auth and not @files;
print_repo($repo_type, $repo_url) if $print_only; # ... then quit
if (length $pkg) {
print "declared $repo_type repository at $repo_url\n";