From 732b8dfa04f56db89c20a210361487ad50a44f08 Mon Sep 17 00:00:00 2001 From: Rodrigo Farias Date: Wed, 17 Oct 2012 14:19:42 -0600 Subject: [PATCH 1/9] Gitweb: increment $s_counter --- SourceGitweb/SourceGitweb.php | 1 + 1 file changed, 1 insertion(+) diff --git a/SourceGitweb/SourceGitweb.php b/SourceGitweb/SourceGitweb.php index eeb7ec27b..7fd6e805d 100644 --- a/SourceGitweb/SourceGitweb.php +++ b/SourceGitweb/SourceGitweb.php @@ -232,6 +232,7 @@ private function import_commits( $p_repo, $p_uri_base, $p_commit_ids, $p_branch= } $s_parents = array_merge( $s_parents, $t_commit_parents ); + $s_counter += 1; } $s_counter = 0; From 5d053be04f6d39e45c29738476600553c4d851f0 Mon Sep 17 00:00:00 2001 From: Rodrigo Farias Date: Wed, 17 Oct 2012 14:24:29 -0600 Subject: [PATCH 2/9] Gitweb: update regex'es for git 1.7.9.5 --- SourceGitweb/SourceGitweb.php | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/SourceGitweb/SourceGitweb.php b/SourceGitweb/SourceGitweb.php index 7fd6e805d..404651df7 100644 --- a/SourceGitweb/SourceGitweb.php +++ b/SourceGitweb/SourceGitweb.php @@ -275,37 +275,31 @@ private function commit_changeset( $p_repo, $p_input, $p_branch='' ) { if ( !SourceChangeset::exists( $p_repo->id, $t_commit['revision'] ) ) { # Parse for commit data - preg_match( '#author(?:]*>)?([^<>]*)(?:)? *(?:]*>)?<([^<>]*)>(?:)?(?:<[^<>]*>\s*)*?\n\w*, (\d* \w* \d* \d*:\d*:\d*)#', $t_gitweb_data, $t_matches ); + preg_match( '#authored by ([^"]*).*?authored by ([^"]*).*?>([^<]*\d*:\d*:\d*[^(<]*)' + . '.*?committed by ([^"]*).*?committed by ([^"]*).*?page_body">(.*?)#', + $t_gitweb_data, $t_matches ); $t_commit['author'] = $t_matches[1]; $t_commit['author_email'] = $t_matches[2]; $t_commit['date'] = date( 'Y-m-d H:i:s', strtotime( $t_matches[3] ) ); - - if( preg_match( '#committer(?:]*>)?([^<>]*)(?:)? *(?:]*>)?<([^<>]*)>(?:)?(?:<[^<>]*>\s*)*?#', $t_gitweb_data, $t_matches ) ) { - $t_commit['committer'] = $t_matches[1]; - $t_commit['committer_email'] = $t_matches[2]; - } + $t_commit['committer'] = $t_matches[4]; + $t_commit['committer_email'] = $t_matches[5]; + $t_commit['message'] = trim( str_replace( '
', PHP_EOL, $t_matches[6] ) ); $t_parents = array(); - if( preg_match_all( '#parent]*>([a-f0-9]*)#', $t_gitweb_data, $t_matches ) ) { + if ( preg_match_all( '#parent<[^>]*h=([0-9a-f]*)#', $t_gitweb_data, $t_matches ) ) { foreach( $t_matches[1] as $t_match ) { $t_parents[] = $t_commit['parent'] = $t_match; } } - preg_match( '#
\n(.*)\n
#', $t_gitweb_data, $t_matches ); - $t_commit['message'] = trim( str_replace( '
', PHP_EOL, $t_matches[1] ) ); - # Strip ref links and signoff spans from commit message - $t_commit['message'] = preg_replace( array( - '@]*>([^<]*)<\/a>@', - '@]*>([^<]*<[^>]*>[^<]*)<\/span>@', #finds signed-off by
- ), '$1', $t_commit['message'] ); + $t_commit['message'] = preg_replace( array( '#]*>([^<]*)#', '#]*>(.*?)#' ), + '$1', $t_commit['message'] ); # Parse for changed file data $t_commit['files'] = array(); - preg_match_all( '#\n([^<>]+)'. - '\n(?:[^<>]*)?#', + preg_match_all( '#class="list".*?h=(\w*)[^>]*>([^<]*)(?:(?: Date: Mon, 29 Oct 2012 13:34:05 -0400 Subject: [PATCH 8/9] Gitweb: handle branch names with '+' character --- SourceGitweb/SourceGitweb.php | 3 +++ SourceGitweb/post-receive.tmpl | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/SourceGitweb/SourceGitweb.php b/SourceGitweb/SourceGitweb.php index 68c28ff77..58ee754eb 100644 --- a/SourceGitweb/SourceGitweb.php +++ b/SourceGitweb/SourceGitweb.php @@ -117,6 +117,9 @@ public function precommit( ) { } public function commit( $p_repo, $p_data ) { + # Handle branch names with '+' character + $p_data = str_replace('_plus_', '+', $p_data); + # The -d option from curl requires you to encode your own data. # Once it reaches here it is decoded. Hence we split by a space # were as the curl command uses a '+' character instead. diff --git a/SourceGitweb/post-receive.tmpl b/SourceGitweb/post-receive.tmpl index f1ce6ee03..03a1add6e 100644 --- a/SourceGitweb/post-receive.tmpl +++ b/SourceGitweb/post-receive.tmpl @@ -4,6 +4,10 @@ # Licensed under the MIT license read LINE + +# Handle branch names with '+' character +LINE=`echo $LINE | sed -e 's/+/_plus_/g'` + LINE=`echo $LINE | sed -e 's/ /+/g'` URL="http://localhost/mantisbt/plugin.php?page=Source/checkin" From 20090356658c2d92515a0d5f1293489b0ea8f713 Mon Sep 17 00:00:00 2001 From: Rodrigo Farias Date: Mon, 29 Oct 2012 15:54:31 -0400 Subject: [PATCH 9/9] Gitweb: handle '+' in import_commits as well --- SourceGitweb/SourceGitweb.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/SourceGitweb/SourceGitweb.php b/SourceGitweb/SourceGitweb.php index 58ee754eb..6c20d0809 100644 --- a/SourceGitweb/SourceGitweb.php +++ b/SourceGitweb/SourceGitweb.php @@ -222,11 +222,14 @@ private function import_commits( $p_repo, $p_uri_base, $p_commit_ids, $p_branch= echo "Retrieving $t_commit_id ... "; - $t_commit_url = $this->uri_base( $p_repo ) . 'a=commit;h=' . $t_commit_id; + # Handle branch names with '+' character + $t_fixed_id = str_replace('+', '%2B', $t_commit_id); + $t_commit_url = $this->uri_base( $p_repo ) . 'a=commit;h=' . $t_fixed_id; $t_input = url_get( $t_commit_url ); if ( false === $t_input ) { echo "failed.\n"; + echo "$t_commit_url\n"; # DEBUG continue; }