Skip to content

Commit c56328e

Browse files
authored
Remove support for filtering MRs based on source and target branch (#62)
1 parent deb185c commit c56328e

File tree

6 files changed

+5
-64
lines changed

6 files changed

+5
-64
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
* 0.15.0:
2+
- Remove support for ancient GitLab versions (#61)
3+
- Remove support for filtering MRs based on source and target branch (#62)
14
* 0.14.1:
25
- Update dependencies (#52)
36
- ci: Run tests on Python 3.11 (#16)

README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,6 @@ optional arguments:
143143
--git-reference-repo GIT_REFERENCE_REPO
144144
A reference repo to be used when git cloning.
145145
[env var: MARGE_GIT_REFERENCE_REPO] (default: None)
146-
--branch-regexp BRANCH_REGEXP
147-
Only process MRs whose target branches match the given regular expression.
148-
[env var: MARGE_BRANCH_REGEXP] (default: .*)
149-
--source-branch-regexp SOURCE_BRANCH_REGEXP
150-
Only process MRs whose source branches match the given regular expression.
151-
[env var: MARGE_SOURCE_BRANCH_REGEXP] (default: .*)
152146
--debug Debug logging (includes all HTTP requests etc).
153147
[env var: MARGE_DEBUG] (default: False)
154148
--cli Run marge-bot as a single CLI command, not as a long-running service.

marge/app.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -199,18 +199,6 @@ def regexp(str_regex):
199199
default=None,
200200
help='A reference repo to be used when git cloning.\n'
201201
)
202-
parser.add_argument(
203-
'--branch-regexp',
204-
type=regexp,
205-
default='.*',
206-
help='Only process MRs whose target branches match the given regular expression.\n',
207-
)
208-
parser.add_argument(
209-
'--source-branch-regexp',
210-
type=regexp,
211-
default='.*',
212-
help='Only process MRs whose source branches match the given regular expression.\n',
213-
)
214202
parser.add_argument(
215203
'--debug',
216204
action='store_true',
@@ -337,8 +325,6 @@ def main(args=None):
337325
project_regexp=options.project_regexp,
338326
git_timeout=options.git_timeout,
339327
git_reference_repo=options.git_reference_repo,
340-
branch_regexp=options.branch_regexp,
341-
source_branch_regexp=options.source_branch_regexp,
342328
merge_order=options.merge_order,
343329
merge_opts=bot.MergeJobOptions.default(
344330
add_tested=options.add_tested,

marge/bot.py

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -136,33 +136,7 @@ def _get_merge_requests(self, project, project_name):
136136
api=self._api,
137137
merge_order=self._config.merge_order,
138138
)
139-
branch_regexp = self._config.branch_regexp
140-
filtered_mrs = [mr for mr in my_merge_requests
141-
if branch_regexp.match(mr.target_branch)]
142-
log.debug(
143-
'MRs that match branch_regexp: %s',
144-
[mr.web_url for mr in filtered_mrs]
145-
)
146-
filtered_out = set(my_merge_requests) - set(filtered_mrs)
147-
if filtered_out:
148-
log.debug(
149-
'MRs that do not match branch_regexp: %s',
150-
[mr.web_url for mr in filtered_out]
151-
)
152-
source_branch_regexp = self._config.source_branch_regexp
153-
source_filtered_mrs = [mr for mr in filtered_mrs
154-
if source_branch_regexp.match(mr.source_branch)]
155-
log.debug(
156-
'MRs that match source_branch_regexp: %s',
157-
[mr.web_url for mr in source_filtered_mrs]
158-
)
159-
source_filtered_out = set(filtered_mrs) - set(source_filtered_mrs)
160-
if source_filtered_out:
161-
log.debug(
162-
'MRs that do not match source_branch_regexp: %s',
163-
[mr.web_url for mr in source_filtered_out]
164-
)
165-
return source_filtered_mrs
139+
return my_merge_requests
166140

167141
def _process_merge_requests(self, repo_manager, project, merge_requests):
168142
if not merge_requests:
@@ -223,7 +197,7 @@ def _get_single_job(self, project, merge_request, repo, config, options):
223197

224198
class BotConfig(namedtuple('BotConfig',
225199
'user use_https auth_token ssh_key_file project_regexp merge_order merge_opts '
226-
+ 'git_timeout git_reference_repo branch_regexp source_branch_regexp batch cli '
200+
+ 'git_timeout git_reference_repo batch cli '
227201
+ 'use_only_gitlab_api')):
228202
pass
229203

tests/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ def create_bot_config(user, options):
1717
project_regexp='',
1818
git_timeout='',
1919
git_reference_repo='',
20-
branch_regexp='',
21-
source_branch_regexp='',
2220
merge_order='created_at',
2321
merge_opts=options,
2422
batch=False,

tests/test_app.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -209,18 +209,6 @@ def test_git_timeout():
209209
assert bot.config.git_timeout == datetime.timedelta(seconds=150)
210210

211211

212-
def test_branch_regexp():
213-
with env(MARGE_AUTH_TOKEN="NON-ADMIN-TOKEN", MARGE_SSH_KEY="KEY", MARGE_GITLAB_URL='http://foo.com'):
214-
with main("--branch-regexp='foo.*bar'") as bot:
215-
assert bot.config.branch_regexp == re.compile('foo.*bar')
216-
217-
218-
def test_source_branch_regexp():
219-
with env(MARGE_AUTH_TOKEN="NON-ADMIN-TOKEN", MARGE_SSH_KEY="KEY", MARGE_GITLAB_URL='http://foo.com'):
220-
with main("--source-branch-regexp='foo.*bar'") as bot:
221-
assert bot.config.source_branch_regexp == re.compile('foo.*bar')
222-
223-
224212
def test_git_reference_repo():
225213
with env(MARGE_AUTH_TOKEN="NON-ADMIN-TOKEN", MARGE_SSH_KEY="KEY", MARGE_GITLAB_URL='http://foo.com'):
226214
with main("--git-reference-repo='/foo/reference_repo'") as bot:
@@ -278,7 +266,6 @@ def test_config_file():
278266
)
279267
assert bot.config.project_regexp == re.compile('foo.*bar')
280268
assert bot.config.git_timeout == datetime.timedelta(seconds=150)
281-
assert bot.config.branch_regexp == re.compile('foo.*bar')
282269

283270

284271
def test_config_overwrites():
@@ -299,4 +286,3 @@ def test_config_overwrites():
299286
)
300287
assert bot.config.project_regexp == re.compile('foo.*bar')
301288
assert bot.config.git_timeout == datetime.timedelta(seconds=100)
302-
assert bot.config.branch_regexp == re.compile('foo.*bar')

0 commit comments

Comments
 (0)