Ignore patches that are listed as sources

The patch live cycle does not apply to them
This commit is contained in:
Stephan Kulow 2022-03-25 07:39:17 +01:00
parent c8531891a1
commit ed87520710
7 changed files with 67 additions and 5 deletions

View File

@ -44,9 +44,6 @@ if (-d "$old") {
if (m/^Source/) {
my $line = $_;
$line =~ s/^(Source[0-9]*)\s*:\s*//;
if ($patches{$line}) {
delete $patches{$line};
}
my $prefix = $1;
my $parsedline = $ps->{lc $prefix};
if (defined $thash{$parsedline}) {

View File

@ -226,7 +226,7 @@ class CheckSource(ReviewBot.ReviewBot):
if not self.run_source_validator('_old', target_package):
return False
if not self.detect_mentioned_patches('_old', target_package):
if not self.detect_mentioned_patches('_old', target_package, specs):
return False
# Run check_source.pl script and interpret output.
@ -585,7 +585,18 @@ class CheckSource(ReviewBot.ReviewBot):
newl = f.readlines()
return list(difflib.unified_diff(oldl, newl))
def detect_mentioned_patches(self, old, directory):
def _mentioned_sources(self, directory, specs):
sources = set()
for spec in specs:
with open(os.path.join(directory, spec)) as f:
for line in f:
m = re.match(r'Source[0-9]*\s*:\s*(.*)$', line)
if not m:
continue
sources.add(m.group(1))
return sources
def detect_mentioned_patches(self, old, directory, specs):
# new packages have different rules
if not os.path.isdir(old):
return True
@ -625,6 +636,13 @@ class CheckSource(ReviewBot.ReviewBot):
del patches_to_mention[patch]
break
# if a patch is mentioned as source, we ignore it
sources = self._mentioned_sources(directory, specs)
sources |= self._mentioned_sources(old, specs)
for s in sources:
patches_to_mention.pop(s, None)
if not patches_to_mention:
return True

View File

@ -151,6 +151,25 @@ class TestCheckSource(OBSLocal.TestCase):
self.assertReview(req_id, by_user=(self.bot_user, 'accepted'))
self.assertReview(req_id, by_group=(REVIEW_TEAM, 'new'))
@pytest.mark.usefixtures("default_config")
def test_patch_as_source(self):
"""Accepts a request if a new patch is a source"""
# switch target and devel, so basically do revert of changes done
# with patch and changes
self._setup_devel_project(devel_files='blowfish-patch-as-source',
target_files='blowfish')
req_id = self.wf.create_submit_request(self.devel_package.project,
self.devel_package.name, add_commit=False).reqid
self.assertReview(req_id, by_user=(self.bot_user, 'new'))
self.review_bot.set_request_ids([req_id])
self.review_bot.check_requests()
self.assertReview(req_id, by_user=(self.bot_user, 'accepted'))
self.assertReview(req_id, by_group=(REVIEW_TEAM, 'new'))
@pytest.mark.usefixtures("required_source_maintainer")
def test_no_source_maintainer(self):
"""Declines the request when the 'required_maintainer' is not maintainer of the source project

Binary file not shown.

View File

@ -0,0 +1,10 @@
-------------------------------------------------------------------
Fri Mar 25 06:18:56 UTC 2022 - Stephan Kulow <coolo@suse.com>
- Not mentioning the patch!
-------------------------------------------------------------------
Thu Jul 8 07:36:30 UTC 2021 - Fisherman <fisherman@opensuse.org>
- Initial version.
- 1

View File

@ -0,0 +1,17 @@
#
# Copyright (c) 2020 SUSE LLC
#
# This file is under MIT license
Name: blowfish
Version: 1
Release: 0
Summary: Blowfish
License: GPL-2.0-only
URL: https://github.com/openSUSE/cockpit-wicked
Source: blowfish-1.tar.gz
Source1: test.patch
BuildArch: noarch
%changelog

View File

@ -0,0 +1 @@
Not really a patch