Skip to content

Commit

Permalink
Allow creating PR without labels (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Nevelson authored Aug 26, 2020
1 parent b80237c commit 602091f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com),
and this project adheres to [Semantic Versioning](https://semver.org).

## [3.1.0] - 2020-08-26
### Added
- Allow `repo#create_pr` to be called without setting labels

## [3.0.1] - 2020-07-29
### Fixed
- Fixed error handling logic when forking to retry when Github returns 404 (because that implies the repo hasn't yet finished forking)
Expand Down
5 changes: 3 additions & 2 deletions gordian/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,15 @@ def delete_file(self, file, message, dry_run=False):
branch=self.branch_name
)

def create_pr(self, pr_message, pr_body, target_branch, labels):
def create_pr(self, pr_message, pr_body, target_branch, labels=[]):
pr = self._target_repo.create_pull(
pr_message,
pr_body,
target_branch,
f'{self._source_repo.owner.login}:{self.branch_name}'
)
pr.set_labels(*labels)
if labels:
pr.set_labels(*labels)
return pr

def _get_new_version(self):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
setup_reqs = ['pytest', 'pytest-cov', 'pytest-runner', 'flake8']
setuptools.setup(
name="gordian",
version="3.0.1",
version="3.1.0",
author="Intuit",
author_email="[email protected]",
description="A tool to search and replace files in a Git repo",
Expand Down
11 changes: 11 additions & 0 deletions tests/test_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,17 @@ def test_create_pr(self):
pr.set_labels.assert_called_once_with('test')
repo._source_repo.create_pull.assert_not_called()

def test_create_pr_no_labels(self):
repo = Repo(None, branch='', github=self.mock_git)
repo._target_repo = MagicMock()
repo._source_repo = MagicMock()
repo._source_repo.owner.login = 'someone'
repo.branch_name = 'branch'
pr = repo.create_pr('test', '', 'target_branch')
repo._target_repo.create_pull.assert_called_once_with('test', '', 'target_branch', 'someone:branch')
pr.set_labels.assert_not_called()
repo._source_repo.create_pull.assert_not_called()

def test__get_new_version_major(self):
version_file = MagicMock()
version_file.decoded_content = '1.2.3'.encode('utf-8')
Expand Down

0 comments on commit 602091f

Please sign in to comment.