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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Queue SVN-Buddy new repository commit discovery, after a new commit in SVN-Buddy was made.
- The `log` and `merge` commands no longer fails with large (>999) revision lists on SQLite <= 3.32.0.
- The deletion of project wasn't deleting its refs (branches/tags) resulting them to reported as existing.
- The attempt to detect a "bugtraq:logregex" of a deleted project failed.

## [0.7.0] - 2024-04-12
### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ protected function populateMissingBugRegExp($cache_overwrite = false)
*/
protected function detectProjectBugTraqRegEx($project_path, $revision, $project_deleted, $cache_overwrite = false)
{
$ref_paths = $this->getLastChangedRefPaths($project_path);
$ref_paths = $this->getLastChangedRefPaths($project_path, $revision, $project_deleted);

if ( !$ref_paths ) {
return '';
Expand All @@ -204,20 +204,30 @@ protected function detectProjectBugTraqRegEx($project_path, $revision, $project_
/**
* Returns given project refs, where last changed are on top.
*
* @param string $project_path Path.
* @param string $project_path Path.
* @param integer $revision Revision.
* @param boolean $project_deleted Project is deleted.
*
* @return array
*/
protected function getLastChangedRefPaths($project_path)
protected function getLastChangedRefPaths($project_path, $revision, $project_deleted)
{
$own_nesting_level = substr_count($project_path, '/') - 1;

$where_clause = array(
'Path LIKE :parent_path',
'PathNestingLevel BETWEEN :from_level AND :to_level',
'RevisionDeleted IS NULL',
);

if ( $project_deleted ) {
// For deleted project scan paths, that existed at project removal time.
$where_clause[] = 'RevisionDeleted > ' . $revision;
}
else {
// For active project scan paths, that are not deleted.
$where_clause[] = 'RevisionDeleted IS NULL';
}

$sql = 'SELECT Path, RevisionLastSeen
FROM Paths
WHERE (' . implode(') AND (', $where_clause) . ')';
Expand All @@ -234,9 +244,9 @@ protected function getLastChangedRefPaths($project_path)

$filtered_paths = array();

foreach ( $paths as $path => $revision ) {
foreach ( $paths as $path => $last_seen_revision ) {
if ( $this->isRef($path) ) {
$filtered_paths[$path] = $revision;
$filtered_paths[$path] = $last_seen_revision;
}
}

Expand Down
16 changes: 14 additions & 2 deletions tests/SVNBuddy/Repository/RevisionLog/Plugin/BugsPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ public function testProcessDetectsMissingBugRegexps($project_deleted)
->addPath('A', '/path/to/project/branches/branch-name/', '', '/path/to/project/')
->addPath('A', '/path/to/project/branches/branch-name/file.txt', '', '/path/to/project/');

if ( $project_deleted ) {
$this->commitBuilder
->addCommit(300, 'user', 0, 'message')
->addPath('D', '/path/to/project/', '', '/path/to/project/');
}

$this->commitBuilder->build();

// Assuming that project id would be "1".
Expand Down Expand Up @@ -211,6 +217,12 @@ public function testBugRegexpsRefresh($project_deleted)
->addPath('A', '/path/to/project/branches/branch-name/', '', '/path/to/project/')
->addPath('A', '/path/to/project/branches/branch-name/file.txt', '', '/path/to/project/');

if ( $project_deleted ) {
$this->commitBuilder
->addCommit(300, 'user', 0, 'message')
->addPath('D', '/path/to/project/', '', '/path/to/project/');
}

$this->commitBuilder->build();

// Assuming that project id would be "1".
Expand Down Expand Up @@ -280,8 +292,8 @@ public function setBugRegexpExpectation($project_deleted, $expression)
public static function processDetectsMissingBugRegexpsDataProvider()
{
return array(
'project deleted' => array('0'),
'project not deleted' => array('1'),
'project alive' => array('0'),
'project deleted' => array('1'),
);
}

Expand Down
Loading