threads / patch / 40204

patchgit-remote-mediawiki: support subpages as subdirectories

Subject: [PATCH] git-remote-mediawiki: support subpages as subdirectories

## tl;dr

2 messages between Aug 28, 2015 and Aug 28, 2015. Diffs are folded; open one to read it.

replies: 1people: 2as markdown or json

Lyubomyr Shaydariv· Aug 28, 2015, 06:14 UTC · lore

This is a fix for https://github.com/moy/Git-Mediawiki/issues/22 The subdirectories option is enabled using -c remote.origin.subpageDirs=true during the cloning and it is not recommended to be modified in or removed from .git/config after the cloning.

Signed-off-by: Lyubomyr Shaydariv <lyubomyr-shaydariv@users.noreply.github.com>
Reported-by: David Garcia Garzon
Reviewed-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
 contrib/mw-to-git/git-remote-mediawiki.perl | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
Show changes to contrib/mw-to-git/git-remote-mediawiki.perl +9 −1
diff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl
index 8dd74a9..f3624be 100755
--- a/contrib/mw-to-git/git-remote-mediawiki.perl
+++ b/contrib/mw-to-git/git-remote-mediawiki.perl
@@ -63,6 +63,11 @@ chomp(@tracked_pages);
 my @tracked_categories = split(/[ \n]/, run_git("config --get-all remote.${remotename}.categories"));
 chomp(@tracked_categories);
 
+# Use subdirectories for subpages
+my $use_subpage_dirs = run_git("config --get --bool remote.${remotename}.subpageDirs");
+chomp($use_subpage_dirs);
+$use_subpage_dirs = ($use_subpage_dirs eq 'true');
+
 # Import media files on pull
 my $import_media = run_git("config --get --bool remote.${remotename}.mediaimport");
 chomp($import_media);
@@ -689,6 +694,9 @@ sub fe_escape_path {
     $path =~ s/\\/\\\\/g;
     $path =~ s/"/\\"/g;
     $path =~ s/\n/\\n/g;
+    if ($use_subpage_dirs) {
+        $path =~ s/%2F/\//g;
+    }
     return qq("${path}");
 }
 
@@ -927,7 +935,7 @@ sub mw_import_revids {
 		# If this is a revision of the media page for new version
 		# of a file do one common commit for both file and media page.
 		# Else do commit only for that page.
-		print {*STDERR} "${n}/", scalar(@{$revision_ids}), ": Revision #$rev->{revid} of $commit{title}\n";
+		print {*STDERR} "${n}/", scalar(@{$revision_ids}), ": Revision #$rev->{revid} of ", fe_escape_path($commit{title}), "\n";
 		import_file_revision(\%commit, ($fetch_from == 1), $n_actual, \%mediafile);
 	}
 
-- 
1.9.1
Junio C Hamano· Aug 28, 2015, 17:31 UTC · re: Lyubomyr Shaydariv · lore

Re: [PATCH] git-remote-mediawiki: support subpages as subdirectories

Lyubomyr Shaydariv <dev.konsole@gmail.com> writes:
> This is a fix for https://github.com/moy/Git-Mediawiki/issues/22

Do not force readers of "git log" to go to the web. Please have a real problem description (I notice that the initial description of issues/22 by vokimon very much readable and you can just use that) before that URL.

> The subdirectories option is enabled using -c remote.origin.subpageDirs=true
> during the cloning and it is not recommended to be modified in or
> removed from .git/config after the cloning.

What happens when I clone without setting it and then later set it (or vice versa)? Does it completely break the resulting repository and/or the MediaWiki side?

What I am wondering is if it is merely "it is not recommended" or it should be a bit stronger in order to save users from hurting themselves. If the possible breakage is minor, a casual mention like the above in the log message may be OK. On the other hand, if it is major enough, we may even want to have a code that forbids flipping the setting in the middle (which may mean that you would have this recorded somewhere outside of the config file).

Show 41 quoted lines
> Signed-off-by: Lyubomyr Shaydariv <lyubomyr-shaydariv@users.noreply.github.com>
> Reported-by: David Garcia Garzon
> Reviewed-by: Matthieu Moy <Matthieu.Moy@imag.fr>
> ---
>  contrib/mw-to-git/git-remote-mediawiki.perl | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl
> index 8dd74a9..f3624be 100755
> --- a/contrib/mw-to-git/git-remote-mediawiki.perl
> +++ b/contrib/mw-to-git/git-remote-mediawiki.perl
> @@ -63,6 +63,11 @@ chomp(@tracked_pages);
>  my @tracked_categories = split(/[ \n]/, run_git("config --get-all remote.${remotename}.categories"));
>  chomp(@tracked_categories);
>  
> +# Use subdirectories for subpages
> +my $use_subpage_dirs = run_git("config --get --bool remote.${remotename}.subpageDirs");
> +chomp($use_subpage_dirs);
> +$use_subpage_dirs = ($use_subpage_dirs eq 'true');
> +
>  # Import media files on pull
>  my $import_media = run_git("config --get --bool remote.${remotename}.mediaimport");
>  chomp($import_media);
> @@ -689,6 +694,9 @@ sub fe_escape_path {
>      $path =~ s/\\/\\\\/g;
>      $path =~ s/"/\\"/g;
>      $path =~ s/\n/\\n/g;
> +    if ($use_subpage_dirs) {
> +        $path =~ s/%2F/\//g;
> +    }
>      return qq("${path}");
>  }
>  
> @@ -927,7 +935,7 @@ sub mw_import_revids {
>  		# If this is a revision of the media page for new version
>  		# of a file do one common commit for both file and media page.
>  		# Else do commit only for that page.
> -		print {*STDERR} "${n}/", scalar(@{$revision_ids}), ": Revision #$rev->{revid} of $commit{title}\n";
> +		print {*STDERR} "${n}/", scalar(@{$revision_ids}), ": Revision #$rev->{revid} of ", fe_escape_path($commit{title}), "\n";
>  		import_file_revision(\%commit, ($fetch_from == 1), $n_actual, \%mediafile);
>  	}

← back to recent threads