Ignore patches that are listed as sources
The patch live cycle does not apply to them
This commit is contained in:
parent
c8531891a1
commit
ed87520710
@ -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}) {
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
BIN
tests/fixtures/packages/blowfish-patch-as-source/blowfish-1.tar.gz
vendored
Normal file
BIN
tests/fixtures/packages/blowfish-patch-as-source/blowfish-1.tar.gz
vendored
Normal file
Binary file not shown.
10
tests/fixtures/packages/blowfish-patch-as-source/blowfish.changes
vendored
Normal file
10
tests/fixtures/packages/blowfish-patch-as-source/blowfish.changes
vendored
Normal 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
|
17
tests/fixtures/packages/blowfish-patch-as-source/blowfish.spec
vendored
Normal file
17
tests/fixtures/packages/blowfish-patch-as-source/blowfish.spec
vendored
Normal 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
|
1
tests/fixtures/packages/blowfish-patch-as-source/test.patch
vendored
Normal file
1
tests/fixtures/packages/blowfish-patch-as-source/test.patch
vendored
Normal file
@ -0,0 +1 @@
|
||||
Not really a patch
|
Loading…
x
Reference in New Issue
Block a user