Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add and implement PullRequest.reopen() #714

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ check:
PYTHONPATH=$(CURDIR) PYTHONDONTWRITEBYTECODE=1 pytest --verbose --showlocals $(TEST_TARGET)

check-in-container:
podman run --rm -it -v $(CURDIR):/src:Z -w /src --env TEST_TARGET $(OGR_IMAGE) make -e GITHUB_TOKEN=$(GITHUB_TOKEN) GITLAB_TOKEN=$(GITLAB_TOKEN) check
podman run --rm -it -v $(CURDIR):/src:Z -w /src --env TEST_TARGET $(OGR_IMAGE) \
make -e GITHUB_TOKEN=$(GITHUB_TOKEN) GITLAB_TOKEN=$(GITLAB_TOKEN) PAGURE_TOKEN=$(PAGURE_TOKEN) check

shell:
podman run --rm -ti -v $(CURDIR):/src:Z -w /src $(OGR_IMAGE) bash
Expand Down
2 changes: 1 addition & 1 deletion files/tasks/build-rpm-deps.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: Install RPM build dependencies
command: dnf -y builddep fedora/python-ogr.spec
ansible.builtin.command: dnf -y builddep fedora/python-ogr.spec
args:
chdir: "{{ project_dir }}"
become: true
4 changes: 2 additions & 2 deletions files/tasks/configure-git.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- name: "set up git: email"
command: git config --global user.email [email protected]
ansible.builtin.command: git config --global user.email [email protected]
- name: "set up git: name"
command: git config --global user.name "OGR Test Suite"
ansible.builtin.command: git config --global user.name "OGR Test Suite"
4 changes: 2 additions & 2 deletions files/tasks/generic-dnf-requirements.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---
- name: Install generic RPM packages
dnf:
ansible.builtin.dnf:
name:
- make
- git
- dnf-utils
- python3-pip
become: true
- name: Install rpmautospec-rpm-macros
dnf:
ansible.builtin.dnf:
name:
- rpmautospec-rpm-macros
# rpmautospec-rpm-macros is not in epel
Expand Down
4 changes: 2 additions & 2 deletions files/tasks/install-ogr.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- name: Print the current working directory
command: pwd
ansible.builtin.command: pwd
- name: Install ogr from {{ project_dir }}
pip:
ansible.builtin.pip:
name: "{{ project_dir }}"
become: true
4 changes: 2 additions & 2 deletions files/tasks/packit-requirements.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
- name: Install ansible
dnf:
ansible.builtin.dnf:
name:
- ansible
state: present
become: true

- name: Install packit dependencies via ansible playbooks
command: ansible-playbook -e "ansible_python_interpreter=/usr/bin/python3" -v -c local -i localhost, files/install-requirements-pip.yaml
ansible.builtin.command: ansible-playbook -e "ansible_python_interpreter=/usr/bin/python3" -v -c local -i localhost, files/install-requirements-pip.yaml
args:
chdir: "{{ reverse_dir }}"
4 changes: 2 additions & 2 deletions files/tasks/packit-tests.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
- name: install and run basic packit tests via ansible playbooks
command: ansible-playbook -e "ansible_python_interpreter=/usr/bin/python3" -v -c local -i localhost, files/zuul-tests.yaml
ansible.builtin.command: ansible-playbook -e "ansible_python_interpreter=/usr/bin/python3" -v -c local -i localhost, files/zuul-tests.yaml
args:
chdir: "{{ reverse_dir }}"
- name: install and run packit tests with session recording via ansible playbooks
command: ansible-playbook -e "ansible_python_interpreter=/usr/bin/python3" -v -c local -i localhost, files/zuul-tests-session-recording.yaml
ansible.builtin.command: ansible-playbook -e "ansible_python_interpreter=/usr/bin/python3" -v -c local -i localhost, files/zuul-tests-session-recording.yaml
args:
chdir: "{{ reverse_dir }}"
8 changes: 4 additions & 4 deletions files/tasks/project-dir.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
- set_fact:
- ansible.builtin.set_fact:
project_dir: "{{ playbook_dir }}/.."
when: zuul is not defined
- set_fact:
- ansible.builtin.set_fact:
project_dir: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}"
when: zuul is defined
- name: stat {{ project_dir }}
stat:
ansible.builtin.stat:
path: "{{ project_dir }}"
tags:
- no-cache
register: src_path
- name: Make sure {{ project_dir }} is present
assert:
ansible.builtin.assert:
that:
- src_path.stat.isdir
2 changes: 1 addition & 1 deletion files/tasks/python-compile-deps.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: Install specific RPMs to be able to use PIP installation
dnf:
ansible.builtin.dnf:
name:
- krb5-devel
- gcc
Expand Down
4 changes: 2 additions & 2 deletions files/tasks/rpm-test-deps.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: Install test rpm dependencies
dnf:
ansible.builtin.dnf:
name:
- python3-pip
- python3-setuptools
Expand All @@ -14,7 +14,7 @@
state: present
become: true
- name: Install requre from git
pip:
ansible.builtin.pip:
name:
- git+https://github.com/packit/requre.git
state: latest
Expand Down
2 changes: 1 addition & 1 deletion files/zuul-install-requirements-pip.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- include_tasks: tasks/generic-dnf-requirements.yaml
- include_tasks: tasks/python-compile-deps.yaml
- name: Install deps from PyPI
pip:
ansible.builtin.pip:
name: "{{ item }}"
with_items:
- PyGithub
Expand Down
2 changes: 1 addition & 1 deletion files/zuul-install-requirements-rpms.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- include_tasks: tasks/generic-dnf-requirements.yaml
- include_tasks: tasks/build-rpm-deps.yaml
- name: Install deps as RPMs
dnf:
ansible.builtin.dnf:
name:
- python3-pygithub
- python3-gitlab
Expand Down
2 changes: 1 addition & 1 deletion files/zuul-reverse-dep-packit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- name: Check if we are not breaking packit
hosts: all
tasks:
- set_fact:
- ansible.builtin.set_fact:
reverse_dir: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/packit/packit'].src_dir }}"
- include_tasks: tasks/project-dir.yaml
- include_tasks: tasks/generic-dnf-requirements.yaml
Expand Down
2 changes: 1 addition & 1 deletion files/zuul-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
- include_tasks: tasks/install-ogr.yaml
- include_tasks: tasks/configure-git.yaml
- name: Run tests
command: make check
ansible.builtin.command: make check
args:
chdir: "{{ project_dir }}"
9 changes: 9 additions & 0 deletions ogr/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,15 @@ def close(self) -> "PullRequest":
"""
raise NotImplementedError()

def reopen(self) -> "PullRequest":
"""
Reopen closed pull request.

Returns:
Pull request itself.
"""
raise NotImplementedError()

def merge(self) -> "PullRequest":
"""
Merge the pull request.
Expand Down
4 changes: 4 additions & 0 deletions ogr/services/github/pull_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ def close(self) -> "PullRequest":
self._raw_pr.edit(state=PRStatus.closed.name)
return self

def reopen(self) -> "PullRequest":
self._raw_pr.edit(state=PRStatus.open.name)
return self

def merge(self) -> "PullRequest":
self._raw_pr.merge()
return self
Expand Down
5 changes: 5 additions & 0 deletions ogr/services/gitlab/pull_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,11 @@ def close(self) -> "PullRequest":
self._raw_pr.save()
return self

def reopen(self) -> "PullRequest":
self._raw_pr.state_event = "reopen"
self._raw_pr.save()
return self

def merge(self) -> "PullRequest":
self._raw_pr.merge()
return self
Expand Down
9 changes: 9 additions & 0 deletions ogr/services/pagure/pull_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,15 @@ def close(self) -> "PullRequest":
self.__dirty = True
return self

def reopen(self) -> "PullRequest":
return_value = self.__call_api("close", method="POST")

if return_value["message"] != "Pull request reopened!":
raise PagureAPIException(return_value["message"])

self.__dirty = True
return self

def merge(self) -> "PullRequest":
return_value = self.__call_api("merge", method="POST")

Expand Down
Loading