From 25e7e9e9698ccb7f59fabdfbf95eeba080e3996c Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Sat, 23 Jan 2016 06:01:04 +0000 Subject: [PATCH] enhanced auto-corelation between issue and code revision --- codepot/etc/post-commit.in | 11 +++++++++-- codepot/etc/post-revprop-change.in | 11 +++++++++-- codepot/src/codepot/views/code_revision.php | 18 ++++++++++++++++-- codepot/src/codepot/views/issue_show.php | 1 + codepot/src/codepot/views/site_home.php | 5 +++-- codepot/src/css/common.css | 8 ++++---- codepot/src/css/issue.css | 8 ++++++-- 7 files changed, 48 insertions(+), 14 deletions(-) diff --git a/codepot/etc/post-commit.in b/codepot/etc/post-commit.in index f5f69741..cb31aabb 100644 --- a/codepot/etc/post-commit.in +++ b/codepot/etc/post-commit.in @@ -115,11 +115,18 @@ sub find_issue_reference_in_commit_message # find [[#IXXXX]] my @issue_ids = ($commit_message =~ /\[\[#I(\d+)\]\]/g); + # find #XXXX + my @issue_ids2 = ($commit_message =~ /(^|[^#])#(\d+)(\D|$)/g); # find unique issue ids in the findings. my %tmp; - @tmp{@issue_ids}=1; - my @unique_issue_ids=keys %tmp; + @tmp{@issue_ids} = 1; + for (my $i = 0; $i < scalar(@issue_ids2); $i += 3) + { + my $id = @issue_ids2[$i + 1]; + @tmp{$id} = 1; + } + my @unique_issue_ids = keys(%tmp); $dbh->begin_work (); diff --git a/codepot/etc/post-revprop-change.in b/codepot/etc/post-revprop-change.in index 932b6bf2..53619894 100644 --- a/codepot/etc/post-revprop-change.in +++ b/codepot/etc/post-revprop-change.in @@ -99,11 +99,18 @@ sub find_issue_reference_in_commit_message # find [[#IXXXX]] my @issue_ids = ($commit_message =~ /\[\[#I(\d+)\]\]/g); + # find #XXXX + my @issue_ids2 = ($commit_message =~ /(^|[^#])#(\d+)(\D|$)/g); # find unique issue ids in the findings. my %tmp; - @tmp{@issue_ids}=1; - my @unique_issue_ids=keys %tmp; + @tmp{@issue_ids} = 1; + for (my $i = 0; $i < scalar(@issue_ids2); $i += 3) + { + my $id = @issue_ids2[$i + 1]; + @tmp{$id} = 1; + } + my @unique_issue_ids = keys(%tmp); $dbh->begin_work (); diff --git a/codepot/src/codepot/views/code_revision.php b/codepot/src/codepot/views/code_revision.php index 35947278..7d5ebd11 100644 --- a/codepot/src/codepot/views/code_revision.php +++ b/codepot/src/codepot/views/code_revision.php @@ -680,14 +680,28 @@ $history = $file['history']; foreach ($related_issues as $ri) { $hex_issueid = $this->converter->AsciiToHex ($ri->issueid); - //$transformed_message = preg_replace ("/\[\[#I{$ri->issueid}\]\]/", anchor ("/issue/show/{$ri->projectid}/{$hex_issueid}", $ri->issueid . ':' . htmlspecialchars($ri->summary), "class='codepot-issue-type-{$ri->type}'"), $transformed_message); - //$transformed_message = preg_replace ("/\[\[(#I{$ri->issueid})\]\]/", "[[\${1}]]", $transformed_message); + + // handle [[#IXXX]] $transformed_message = preg_replace ( "/\[\[(#I{$ri->issueid})\]\]/", '[[' . anchor ("/issue/show/{$ri->projectid}/{$hex_issueid}", "\${1}", "class='codepot-issue-type-{$ri->type}'") . ']]', $transformed_message ); + + // handle #XXXX. ##XXXX or some weird variants are not allowed. + $transformed_message = preg_replace ( + "/(^|[^#])#{$ri->issueid}([^[:digit:]]|$)/", + "\${1}" . anchor ("/issue/show/{$ri->projectid}/{$hex_issueid}", "#{$ri->issueid}", "class='codepot-issue-type-{$ri->type}'") . "\${2}", + $transformed_message + ); } + + // handle [[#RXXX]] + $transformed_message = preg_replace ( + "/\[\[(#R([[:digit:]]+))\]\]/", + '[[' . anchor ("/code/revision/{$project->id}/!./\${2}", "\${1}", "class='codepot-hashed-revision-number'") . ']]', + $transformed_message + ); ?>
diff --git a/codepot/src/codepot/views/issue_show.php b/codepot/src/codepot/views/issue_show.php index a22a6b6e..dc8a955d 100644 --- a/codepot/src/codepot/views/issue_show.php +++ b/codepot/src/codepot/views/issue_show.php @@ -1012,6 +1012,7 @@ function print_issue_state ($con, $issue, $old, $issue_type_array, $issue_status if (!empty($related_code_revisions)) { print '