forked from raycast/script-commands
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgitlab-mergerequests.template.py
executable file
·55 lines (43 loc) · 1.56 KB
/
gitlab-mergerequests.template.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python3
# How to use this script?
# It's a template which needs further setup. Duplicate the file,
# remove `.template.` from the filename and set an Personal access token as
# well as the GitLab instance url if it is not gitlab.com in gitlabconfig.py
# You need to copy gitlabconfig.py and gitlabhelper.py next to the script command
# otherwise it won't work. gitlabconfig.py and gitlabhelper.py are shared between
# all gitlab script commands.
#
# API: https://docs.gitlab.com/ee/api
# Parameters
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Merge Requests
# @raycast.mode fullOutput
# Optional parameters:
# @raycast.packageName GitLab
# @raycast.icon images/gitlab.png
# Documentation:
# @raycast.author Michael Aigner
# @raycast.authorURL https://github.com/tonka3000
# @raycast.description Show merge requests from GitLab
# Configuration
# see gitlabconfig.py
# Main program
from gitlabhelper import GitLab
import textwrap
gitlab = GitLab()
data = gitlab.get_call("merge_requests?state=opened&scope=assigned_to_me")
print(f"GitLab Merge requests assigned to you on {gitlab.instance}/:\n")
for e in data:
title = e.get("title")
state = e.get("state")
web_url = e.get("web_url")
author = e.get("author")
name = author.get("name")
username = author.get("username")
reference = e.get("references", {}).get("full")
description = textwrap.shorten(e.get("description"), width=420, placeholder="...")
print(f"[{state}] * {title} at {reference}\n")
print(f"{description}\n")
print(f"{web_url}\n")
print(f"By {name} @{username}\n")