Skip to content

Commit 5ada868

Browse files
Perdugitster
authored andcommitted
git-remote-mediawiki: display message when launched directly
Users may be confused when they run the perl script directly. A good way to detect this is to check the number of parameters used to call the script, which is never different from 2 in a normal use. Display a proper error message to avoid any confusion. Signed-off-by: Célestin Matte <[email protected]> Signed-off-by: Matthieu Moy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent edca415 commit 5ada868

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

contrib/mw-to-git/git-remote-mediawiki.perl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@
4141
# Used on Git's side to reflect empty edit messages on the wiki
4242
use constant EMPTY_MESSAGE => '*Empty MediaWiki Message*';
4343

44+
if (@ARGV != 2) {
45+
exit_error_usage();
46+
}
47+
4448
my $remotename = $ARGV[0];
4549
my $url = $ARGV[1];
4650

@@ -156,6 +160,17 @@
156160

157161
########################## Functions ##############################
158162

163+
## error handling
164+
sub exit_error_usage {
165+
die "ERROR: git-remote-mediawiki module was not called with a correct number of\n" .
166+
"parameters\n" .
167+
"You may obtain this error because you attempted to run the git-remote-mediawiki\n" .
168+
"module directly.\n" .
169+
"This module can be used the following way:\n" .
170+
"\tgit clone mediawiki://<address of a mediawiki>\n" .
171+
"Then, use git commit, push and pull as with every normal git repository.\n";
172+
}
173+
159174
## credential API management (generic functions)
160175

161176
sub credential_read {

0 commit comments

Comments
 (0)