git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lyubomyr Shaydariv <dev.konsole@gmail.com>
To: git@vger.kernel.org
Cc: Lyubomyr Shaydariv <lyubomyr-shaydariv@users.noreply.github.com>,
	Matthieu.Moy@imag.fr
Subject: [PATCH] git-remote-mediawiki: support subpages as subdirectories
Date: Fri, 28 Aug 2015 09:14:46 +0300	[thread overview]
Message-ID: <1440742486-4356-1-git-send-email-lyubomyr-shaydariv@users.noreply.github.com> (raw)

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(-)

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

             reply	other threads:[~2015-08-28  6:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-28  6:14 Lyubomyr Shaydariv [this message]
2015-08-28 17:31 ` [PATCH] git-remote-mediawiki: support subpages as subdirectories Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1440742486-4356-1-git-send-email-lyubomyr-shaydariv@users.noreply.github.com \
    --to=dev.konsole@gmail.com \
    --cc=Matthieu.Moy@imag.fr \
    --cc=git@vger.kernel.org \
    --cc=lyubomyr-shaydariv@users.noreply.github.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).