From 2405fd714bfa676a38ed916b17ba4bcdc551a39a Mon Sep 17 00:00:00 2001 From: blag Date: Mon, 21 Dec 2020 16:06:24 -0800 Subject: [PATCH 1/2] Add action for creating a pull request --- actions/create_pull_request.py | 13 ++++++++++++ actions/create_pull_request.yaml | 36 ++++++++++++++++++++++++++++++++ actions/lib/action.py | 7 +++++++ 3 files changed, 56 insertions(+) create mode 100644 actions/create_pull_request.py create mode 100644 actions/create_pull_request.yaml diff --git a/actions/create_pull_request.py b/actions/create_pull_request.py new file mode 100644 index 0000000..6680c85 --- /dev/null +++ b/actions/create_pull_request.py @@ -0,0 +1,13 @@ +from lib.action import BitBucketAction + + +class CreatePullRequestAction(BitBucketAction): + def run(self, project, repository, title, description, source, target, reviewers=None): + client = self._get_stashy_client() + return list( + client.projects[project].repos[repository].pull_requests.create( + title, + description, + source, + target, + reviewers)) diff --git a/actions/create_pull_request.yaml b/actions/create_pull_request.yaml new file mode 100644 index 0000000..e53eb89 --- /dev/null +++ b/actions/create_pull_request.yaml @@ -0,0 +1,36 @@ +name: create_pull_request +description: Create a pull request +enabled: true +runner_type: python-script +entry_point: create_pull_request.py +parameters: + project: + type: string + description: Bitbucket project the repo is under + required: true + repository: + type: string + description: Name of the repository + required: true + title: + type: string + description: Pull request title/short description + required: true + description: + type: string + description: Pull request description + required: true + source: + type: string + description: The branch name, tag, or commit hash to merge from + required: true + target: + type: string + description: The branch name, tag, or commit hash to merge into + required: true + reviewers: + type: array + description: List of usernames to add as reviewers + required: false + items: + type: string diff --git a/actions/lib/action.py b/actions/lib/action.py index 9292361..fff87ab 100755 --- a/actions/lib/action.py +++ b/actions/lib/action.py @@ -15,3 +15,10 @@ def _get_client(self, repo=None): bb = Bitbucket(username=self.config['email'], password=self.config['password']) return bb + + def _get_stashy_client(self): + # Late import to avoid clutter + import stashy + return stashy.connect(self.config['sensor']['bitbucket_server_url'], + self.config['username'], + self.config['password']) From 0ee47dc553ac99d7472b3efd6470e78bf7fd0e5e Mon Sep 17 00:00:00 2001 From: blag Date: Mon, 21 Dec 2020 16:08:21 -0800 Subject: [PATCH 2/2] Update changelog and bump version to 0.6.0 --- CHANGES.md | 4 ++++ pack.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 927e881..ce9aa0c 100755 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ # Change Log +# 0.6.0 + +- Added an action `open_pull_request` + # 0.5.3 - Added a parameter `changed_files` on the dispatching payload to enable to identify the changed files in the updated commits. diff --git a/pack.yaml b/pack.yaml index 665ae2f..4176df9 100755 --- a/pack.yaml +++ b/pack.yaml @@ -8,7 +8,7 @@ keywords: - mercurial - git - source control -version: 0.5.4 +version: 0.6.0 stackstorm_version: ">=2.1.0" author: Aamir email: raza.aamir01@gmail.com