mirror of
https://github.com/openSUSE/osc.git
synced 2025-09-06 13:18:42 +02:00
Add 'git-obs pr show-patch' command
This commit is contained in:
27
osc/commands_git/pr_show_patch.py
Normal file
27
osc/commands_git/pr_show_patch.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import osc.commandline_git
|
||||
|
||||
|
||||
class PullRequestShowPatchCommand(osc.commandline_git.GitObsCommand):
|
||||
"""
|
||||
Show patch associated to the specified pull request
|
||||
"""
|
||||
|
||||
name = "show-patch"
|
||||
parent = "PullRequestCommand"
|
||||
|
||||
def init_arguments(self):
|
||||
from osc.commandline_git import complete_pr
|
||||
|
||||
self.add_argument_owner_repo_pull().completer = complete_pr
|
||||
|
||||
def run(self, args):
|
||||
from osc import gitea_api
|
||||
from osc.core import highlight_diff
|
||||
from osc.output import tty
|
||||
|
||||
self.print_gitea_settings()
|
||||
|
||||
owner, repo, pull = args.owner_repo_pull
|
||||
patch = gitea_api.PullRequest.get_patch(self.gitea_conn, owner, repo, pull)
|
||||
patch = highlight_diff(patch)
|
||||
print(patch.decode("utf-8"))
|
Reference in New Issue
Block a user