git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH/RFC] git-remote-mediawiki: new tool to preview local changes without pushing

From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Date
Jun 8, 2013, 19:00 UTC
Message-ID
<vpqzjv0tokx.fsf@anie.imag.fr>
In-Reply-To
<1370641831-9115-1-git-send-email-benoit.person@ensimag.fr>
benoit.person@ensimag.fr writes:
Show 8 quoted lines
> From: Benoit Person <benoit.person@ensimag.fr>
>
> The #7 issue on git-mediawiki's issue tracker [1] states that the ability to
> preview content without pushing would be a nice thing to have.
>
> This commit is a first attempt to achieve it. It adds a new git command,
> named `git mw`. This command accepts the subcommands `help` and `preview`
> for now.

Review could be easier if you have PATCH 1/2 introducing the command with only "help" (essentially to check that the build system works), and then focus on "preview".

I won't insist in splitting this particular commit, just take it as an advice for future work.

Show 7 quoted lines
> --- a/contrib/mw-to-git/Makefile
> +++ b/contrib/mw-to-git/Makefile
> @@ -5,13 +5,17 @@
>  ## Build git-remote-mediawiki
>  
>  SCRIPT_PERL=git-remote-mediawiki.perl
> +SCRIPT_PERL_MW=git-mw.perl

Why do you need another variable? Just adding git-mw.perl to SCRIPT_PERL should do it, no? (Well, probably the make SCRIPT_PERL=$(SCRIPT_PERL) lacks quotes around the argument, but then you should fix that).

> +# Constants
> +# Mediawiki filenames can contain forward slashes. This variable decides by which pattern they should be replaced
> +Readonly::scalar $SLASH_REPLACEMENT => "%2F";

This one is copied from git-remote-mediawiki.perl, and is a git-mediawiki specific thing, so it would not make sense to put it into Git.pm. This starts convincing me that we should have a GitMediawiki.pm or so, and both scripts should use it.

Another option would be to put everything in git-remote-mediawiki.perl, and probably to have "git mw" as a wrapper around it (to avoid having to type "git remote-mediawiki" which is a bit long).

But the script starts being a bit long, so I think it makes more sense to split it. So I'd say

PATCH 1/3 : introduce "git mw"
PATCH 2/3 : move sharable code to a new module (and make sure it's
            installed properly by "make install")
PATCH 3/3 : actually implement the preview feature
Perhaps others will have other/better advices.
> +	# Auto-loading in browser
> +	if ($autoload) {
> +		open(my $browser, "-|:encoding(UTF-8)", "xdg-open ".$preview_file_name);

That could be read from Git's configuration, and default to xdg-open. But you don't want to hardcode it in the middle of the code.

Also, why use open if you don't want to communicate with the process? system would be sufficient, and won't need close.

Prefer passing an array of arguments, instead of concatenating strings and then rely on command-line parsing to re-split it.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Previous: benoit.person@ensimag.frNext: Jeff King
Message 2 of 14 in “git-remote-mediawiki: new tool to preview local changes without pushing”
  1. git-remote-mediawiki: new tool to preview local changes without pushingbenoit.person@ensimag.fr, Jun 7, 2013
  2. Matthieu MoyJun 8, 2013
  3. Jeff KingJun 9, 2013
  4. Jeff KingJun 9, 2013
  5. Matthieu MoyJun 9, 2013
  6. Benoît PersonJun 9, 2013
  7. Jeff KingJun 9, 2013
  8. Benoît PersonJun 9, 2013
  9. Matthieu MoyJun 9, 2013
  10. Jeff KingJun 9, 2013
  11. Benoît PersonJun 11, 2013
  12. Jeff KingJun 11, 2013
  13. Matthieu MoyJun 12, 2013
  14. Jeff KingJun 12, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.