From: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
To: Kim Thuat NGUYEN <kim-thuat.nguyen@ensimag.imag.fr>
Cc: git@vger.kernel.org, nguyenkimthuat <nguyenkimthuat@gmail.com>,
VOLEK Pavel <Pavel.Volek@ensimag.imag.fr>,
ROUCHER IGLESIAS Javier <roucherj@ensimag.imag.fr>
Subject: Re: [PATCHv2] git-remote-mediawiki: export File: attachments
Date: Tue, 12 Jun 2012 14:52:34 +0200 [thread overview]
Message-ID: <vpqvciwu1yl.fsf@bauges.imag.fr> (raw)
In-Reply-To: <1339505176-2962-1-git-send-email-nguyenkimthuat@gmail.com> (Kim Thuat NGUYEN's message of "Tue, 12 Jun 2012 14:46:16 +0200")
Kim Thuat NGUYEN <kim-thuat.nguyen@ensimag.imag.fr> writes:
> From: nguyenkimthuat <nguyenkimthuat@gmail.com>
Please use your @ensimag email for Ensimag-related things. This adress
is the one used in the commit itself, i.e. ~/.gitconfig. "git commit
--reset-author" can help.
> @@ -644,6 +652,10 @@ sub mw_push_file {
> my $page_deleted = ($new_sha1 eq NULL_SHA1);
> $complete_file_name = mediawiki_clean_filename($complete_file_name);
>
> + my $path = "File:".$complete_file_name;
> + my @extensions = split(/\./, $complete_file_name);
> + my $extension = pop(@extensions);
> +
> if (substr($complete_file_name,-3) eq ".mw") {
> my $title = substr($complete_file_name,0,-3);
If you extract the extension explicitely, then you don't need these
"substr(...)" anymore.
> + my %hashFiles = get_file_extensions();
> + if (exists($hashFiles{$extension})) {
> + # Deleting and uploading a file require the priviledge of the user
> + if ($page_deleted) {
> + mw_connect_maybe();
> + my $res = $mediawiki->edit( {
> + action => 'delete',
> + title => $path,
> + reason => $summary
> + } )|| die $mediawiki-> {error}->{code} . ':' . $mediawiki->{error}->{details};
Here and below: you still have too long lines.
> + ignorewarnings=>1,
Spaces around =>.
> + }, {
> + skip_encoding => 1 # Helps with names with accentuated characters
> + } ) || die $mediawiki-> {error}->{code} . ':' . $mediawiki->{error}->{details};
Weird indentation.
> + } else {
> + print STDERR "Empty file. Can not upload \n ";
> + }
No space, but a "." before \n.
> + } else {
> + print STDERR "$complete_file_name not a mediawiki file (Not pushable on this version of git-remote-mediawiki).\n";
> + }
Why does this message keep reappearing?
> +sub get_file_extensions {
> + mw_connect_maybe();
> +
> + my $query = {
> + action => 'query',
> + meta => 'siteinfo',
> + siprop => 'fileextensions'
> + };
> + my $result = $mediawiki->api($query);
> + my @file_extensions= map $_->{ext},@{$result->{query}->{fileextensions}};
> + my %hashFile = map {$_ => 1}@file_extensions;
> +
> + return %hashFile;
> +}
I like the new function much more than the previous one.
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
next prev parent reply other threads:[~2012-06-12 12:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-12 12:46 [PATCHv2] git-remote-mediawiki: export File: attachments Kim Thuat NGUYEN
2012-06-12 12:52 ` Matthieu Moy [this message]
2012-06-12 12:54 ` nguyenki
2012-06-12 13:51 ` Max Horn
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=vpqvciwu1yl.fsf@bauges.imag.fr \
--to=matthieu.moy@grenoble-inp.fr \
--cc=Pavel.Volek@ensimag.imag.fr \
--cc=git@vger.kernel.org \
--cc=kim-thuat.nguyen@ensimag.imag.fr \
--cc=nguyenkimthuat@gmail.com \
--cc=roucherj@ensimag.imag.fr \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.