Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: minor
Type: changed

Support merge strategy for jetpack changelogger, assuming that merge commits contains the pr number in the merge commit with format (#{pr_number}) towards the end.

2 changes: 1 addition & 1 deletion projects/packages/changelogger/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"extra": {
"autotagger": true,
"branch-alias": {
"dev-trunk": "3.2.x-dev"
"dev-trunk": "3.3.x-dev"
},
"mirror-repo": "Automattic/jetpack-changelogger",
"version-constants": {
Expand Down
2 changes: 1 addition & 1 deletion projects/packages/changelogger/src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
class Application extends SymfonyApplication {

const VERSION = '3.2.3';
const VERSION = '3.3.0-alpha';

/**
* Constructor.
Expand Down
9 changes: 6 additions & 3 deletions projects/packages/changelogger/src/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public static function getRepoData( $file, OutputInterface $output, DebugFormatt
);

try {
$process = self::runCommand( array( 'git', 'log', '-1', "--format=%cI\n%s", $file ), $output, $formatter );
$process = self::runCommand( array( 'git', 'log', '-1', '--first-parent', "--format=%cI\n%s", $file ), $output, $formatter );
if ( $process->isSuccessful() ) {
$cmd_output = explode( "\n", trim( $process->getOutput() ) );

Expand All @@ -188,10 +188,13 @@ public static function getRepoData( $file, OutputInterface $output, DebugFormatt
// PR number.
if ( isset( $cmd_output[1] ) ) {
$matches = array();
preg_match( '/\(#(\d+)\)$/', $cmd_output[1], $matches );
if ( isset( $matches[1] ) ) {
preg_match( '/(?:^Merge pull request #(\d+))|(?:\(#(\d+)\)$)/', $cmd_output[1], $matches );
if ( ! empty( $matches[1] ) ) {
$repo_data['pr-num'] = $matches[1];
}
if ( ! empty( $matches[2] ) ) {
$repo_data['pr-num'] = $matches[2];
}
}
}
// phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ public function testLoadChangeFile_badFile() {
}

/**
* Test getRepoData
* Test getRepoData with squash and merge commits.
*/
public function testGetRepoData() {
$this->useTempDir();
Expand Down Expand Up @@ -389,10 +389,18 @@ public function testGetRepoData() {
),
),
);
Utils::runCommand( array( 'git', 'init', '.' ), ...$args );
Utils::runCommand( array( 'git', 'init', '-b', 'main', '.' ), ...$args );
Utils::runCommand( array( 'git', 'add', 'in-git.txt' ), ...$args );
Utils::runCommand( array( 'git', 'commit', '-m', 'Commit (#123)' ), ...$args );

// Let's create another branch, add a commit and merge to trunk.
Utils::runCommand( array( 'git', 'checkout', '-b', 'temp' ), ...$args );
file_put_contents( 'in-git2.txt', '' );
Utils::runCommand( array( 'git', 'add', 'in-git2.txt' ), ...$args );
Utils::runCommand( array( 'git', 'commit', '-m', 'Dummy commit message.' ), ...$args );
Utils::runCommand( array( 'git', 'checkout', 'main' ), ...$args );
Utils::runCommand( array( 'git', 'merge', 'temp', '--no-ff', '-m', 'Merge pull request #124 from temp.' ), ...$args );

$this->assertSame(
array(
'timestamp' => '2021-02-02T22:22:22+00:00',
Expand All @@ -401,6 +409,15 @@ public function testGetRepoData() {
Utils::getRepoData( 'in-git.txt', $output, $helper )
);

// Test the second commit.
$this->assertSame(
array(
'timestamp' => '2021-02-02T22:22:22+00:00',
'pr-num' => '124',
),
Utils::getRepoData( 'in-git2.txt', $output, $helper )
);

// Test our non-git file again.
$this->assertSame(
array(
Expand Down
5 changes: 5 additions & 0 deletions projects/plugins/backup/changelog/changelogger-merge
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: added
Comment: Minor update to changelog package that supports git merge strategy. Should not affect shipped code.


4 changes: 2 additions & 2 deletions projects/plugins/backup/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions projects/plugins/beta/changelog/changelogger-merge
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: added
Comment: Minor update to changelog package that supports git merge strategy. Should not affect shipped code.


4 changes: 2 additions & 2 deletions projects/plugins/beta/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions projects/plugins/boost/changelog/changelogger-merge
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: added
Comment: Minor update to changelog package that supports git merge strategy. Should not affect shipped code.


4 changes: 2 additions & 2 deletions projects/plugins/boost/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions projects/plugins/debug-helper/changelog/changelogger-merge
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: added
Comment: Minor update to changelog package that supports git merge strategy. Should not affect shipped code.


4 changes: 2 additions & 2 deletions projects/plugins/debug-helper/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: added
Comment: Minor update to changelog package that supports git merge strategy. Should not affect shipped code.


4 changes: 2 additions & 2 deletions projects/plugins/jetpack-mu-wpcom/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions projects/plugins/jetpack/changelog/changelogger-merge
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: enhancement

Also support git merge strategy for changelog.'
4 changes: 2 additions & 2 deletions projects/plugins/jetpack/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions projects/plugins/protect/changelog/changelogger-merge
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: added
Comment: Minor update to changelog package that supports git merge strategy. Should not affect shipped code.


4 changes: 2 additions & 2 deletions projects/plugins/protect/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions projects/plugins/search/changelog/changelogger-merge
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: added
Comment: Minor update to changelog package that supports git merge strategy. Should not affect shipped code.


4 changes: 2 additions & 2 deletions projects/plugins/search/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions projects/plugins/social/changelog/changelogger-merge
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: added
Comment: Minor update to changelog package that supports git merge strategy. Should not affect shipped code.


4 changes: 2 additions & 2 deletions projects/plugins/social/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions projects/plugins/starter-plugin/changelog/changelogger-merge
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: added
Comment: Minor update to changelog package that supports git merge strategy. Should not affect shipped code.


4 changes: 2 additions & 2 deletions projects/plugins/starter-plugin/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions projects/plugins/super-cache/changelog/changelogger-merge
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: added
Comment: Minor update to changelog package that supports git merge strategy. Should not affect shipped code.


4 changes: 2 additions & 2 deletions projects/plugins/super-cache/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions projects/plugins/vaultpress/changelog/changelogger-merge
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: added
Comment: Minor update to changelog package that supports git merge strategy. Should not affect shipped code.


4 changes: 2 additions & 2 deletions projects/plugins/vaultpress/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions projects/plugins/videopress/changelog/changelogger-merge
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: added
Comment: Minor update to changelog package that supports git merge strategy. Should not affect shipped code.


Loading