40
40
# Used on Git's side to reflect empty edit messages on the wiki
41
41
use constant EMPTY_MESSAGE => ' *Empty MediaWiki Message*' ;
42
42
43
+ use constant EMPTY => q{ } ;
44
+
43
45
my $remotename = $ARGV [0];
44
46
my $url = $ARGV [1];
45
47
@@ -150,11 +152,11 @@ sub parse_command {
150
152
mw_list($cmd [1]);
151
153
} elsif ($cmd [0] eq ' import' ) {
152
154
die (" Invalid arguments for import\n " )
153
- if ($cmd [1] eq " " || defined ($cmd [2]));
155
+ if ($cmd [1] eq EMPTY || defined ($cmd [2]));
154
156
mw_import($cmd [1]);
155
157
} elsif ($cmd [0] eq ' option' ) {
156
158
die (" Too many arguments for option\n " )
157
- if ($cmd [1] eq " " || $cmd [2] eq " " || defined ($cmd [3]));
159
+ if ($cmd [1] eq EMPTY || $cmd [2] eq EMPTY || defined ($cmd [3]));
158
160
mw_option($cmd [1],$cmd [2]);
159
161
} elsif ($cmd [0] eq ' push' ) {
160
162
mw_push($cmd [1]);
@@ -555,7 +557,7 @@ sub mediawiki_clean {
555
557
# Mediawiki does not allow blank space at the end of a page and ends with a single \n.
556
558
# This function right trims a string and adds a \n at the end to follow this rule
557
559
$string =~ s /\s +$// ;
558
- if ($string eq " " && $page_created ) {
560
+ if ($string eq EMPTY && $page_created ) {
559
561
# Creating empty pages is forbidden.
560
562
$string = EMPTY_CONTENT;
561
563
}
@@ -566,7 +568,7 @@ sub mediawiki_clean {
566
568
sub mediawiki_smudge {
567
569
my $string = shift ;
568
570
if ($string eq EMPTY_CONTENT) {
569
- $string = " " ;
571
+ $string = EMPTY ;
570
572
}
571
573
# This \n is important. This is due to mediawiki's way to handle end of files.
572
574
return " ${string} \n " ;
@@ -992,7 +994,7 @@ sub mw_upload_file {
992
994
} else {
993
995
# Don't let perl try to interpret file content as UTF-8 => use "raw"
994
996
my $content = run_git(" cat-file blob ${new_sha1} " , ' raw' );
995
- if ($content ne " " ) {
997
+ if ($content ne EMPTY ) {
996
998
mw_connect_maybe();
997
999
$mediawiki -> {config }-> {upload_url } =
998
1000
" ${url} /index.php/Special:Upload" ;
@@ -1034,7 +1036,7 @@ sub mw_push_file {
1034
1036
my $newrevid ;
1035
1037
1036
1038
if ($summary eq EMPTY_MESSAGE) {
1037
- $summary = ' ' ;
1039
+ $summary = EMPTY ;
1038
1040
}
1039
1041
1040
1042
my $new_sha1 = $diff_info_split [3];
@@ -1045,7 +1047,7 @@ sub mw_push_file {
1045
1047
1046
1048
my ($title , $extension ) = $complete_file_name =~ / ^(.*)\. ([^\. ]*)$ / ;
1047
1049
if (!defined ($extension )) {
1048
- $extension = " " ;
1050
+ $extension = EMPTY ;
1049
1051
}
1050
1052
if ($extension eq ' mw' ) {
1051
1053
my $ns = get_mw_namespace_id_for_page($complete_file_name );
@@ -1113,7 +1115,7 @@ sub mw_push {
1113
1115
if ($force ) {
1114
1116
print {*STDERR } " Warning: forced push not allowed on a MediaWiki.\n " ;
1115
1117
}
1116
- if ($local eq " " ) {
1118
+ if ($local eq EMPTY ) {
1117
1119
print {*STDERR } " Cannot delete remote branch on a MediaWiki\n " ;
1118
1120
print {*STDOUT } " error ${remote} cannot delete\n " ;
1119
1121
next ;
0 commit comments