Skip to content

Commit 25d2959

Browse files
davewooddregad
authored andcommitted
Gitweb: error handling when commit URL returns no data
Prior to this, the code did a strict-type check of url_get()'s return value === false, but the function actually returns NULL in case of failure. We now check for a non-empty string, which should properly catch any error encountered by url_get(). In addition, the error message was improved to provide more useful information to the user. Fixes #150, #151 Signed-off-by: Damien Regad <[email protected]> Change from original contribution: - fixed whitespace - reworded error message - detailed commit message
1 parent 8e25462 commit 25d2959

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

SourceGitweb/SourceGitweb.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,10 @@ private function import_commits( $p_repo, $p_uri_base, $p_commit_ids, $p_branch=
227227
$t_commit_url = $this->uri_base( $p_repo ) . 'a=commit;h=' . $t_fixed_id;
228228
$t_input = url_get( $t_commit_url );
229229

230-
if ( false === $t_input ) {
230+
if ( !$t_input ) {
231231
echo "failed.\n";
232-
echo "$t_commit_url\n"; # DEBUG
233-
continue;
232+
echo "'$t_commit_url' did not return any data.\n";
233+
die();
234234
}
235235

236236
list( $t_changeset, $t_commit_parents ) = $this->commit_changeset( $p_repo, $t_input, $p_branch );
@@ -250,11 +250,11 @@ private function commit_changeset( $p_repo, $p_input, $p_branch='' ) {
250250

251251
$t_input = str_replace( array("\r", "\n", '&lt;', '&gt;', '&nbsp;'), array('', '', '<', '>', ' '), $p_input );
252252

253-
# Exract sections of commit data and changed files
253+
# Extract sections of commit data and changed files
254254
$t_input_p1 = strpos( $t_input, '<div class="title_text">' );
255255
$t_input_p2 = strpos( $t_input, '<div class="list_head">' );
256256
if ( false === $t_input_p1 || false === $t_input_p2 ) {
257-
echo 'commit data failure.';
257+
echo "commit data failure.\n";
258258
var_dump( strlen( $t_input ), $t_input_p1, $t_input_p2 );
259259
die();
260260
}

0 commit comments

Comments
 (0)