Kim Thuat NGUYEN <kim-thuat.nguyen@xxxxxxxxxxxxxxx> writes: > From: nguyenkimthuat <nguyenkimthuat@xxxxxxxxx> 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/ -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html