Skip to content

Commit

Permalink
feat: improve GitHub PR creation
Browse files Browse the repository at this point in the history
Signed-off-by: wrightbradley <[email protected]>
  • Loading branch information
wrightbradley committed Oct 31, 2024
1 parent 2f8cfa6 commit b1d968a
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 33 deletions.
45 changes: 45 additions & 0 deletions home/bin/executable_get-jira-title.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "requests",
# ]
# ///
import requests
from requests.auth import HTTPBasicAuth
import argparse
import json
import os

jira_home_directory = os.environ["JIRA_CONFIG_HOME"]
config_path = os.path.join(jira_home_directory, "jira-config.json")
with open(config_path) as config_file:
config = json.load(config_file)

jira_url = config["jira_url"]
api_token = config["api_token"]
email = config["email"]

parser = argparse.ArgumentParser(
description="Get the title of a Jira ticket using the ticket ID."
)
parser.add_argument(
"ticket_id", nargs="?", default=None, help="The ID of the Jira ticket (optional)"
)
args = parser.parse_args()
if args.ticket_id is None:
print("WIP")
else:
ticket_id = args.ticket_id

headers = {"Accept": "application/json", "Content-Type": "application/json"}
response = requests.get(
f"{jira_url}/rest/api/3/issue/{ticket_id}",
headers=headers,
auth=HTTPBasicAuth(email, api_token),
)
if response.status_code == 200:
data = response.json()
title = data["fields"]["summary"]
print(f"{ticket_id}: {title}")
else:
print(f"{ticket_id}")
2 changes: 1 addition & 1 deletion home/dot_config/lazygit/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ os:
edit: 'nvim --server $NVIM --remote-tab {{filename}}'
customCommands:
- key: "<c-g>"
command: "unset GITHUB_TOKEN; JIRA_ID=$(git symbolic-ref --short HEAD | grep -e '\\b[A-Z][A-Z0-9_]\\+-[1-9][0-9]\\+' -o); TITLE=$(uv run ~/bin/get-jira-title.py ${JIRA_ID}); BODY=$(git log --graph --pretty=format:'%C(bold yellow)%h%C(reset) %s%C(auto)%d%C(reset)' origin/main..HEAD | sed 's/\"//g'); echo $BODY > /tmp/body.txt; gh pr create --body \"${BODY}\" --title \"${TITLE}\" --assignee @me {{.Form.DRAFT}} {{.Form.CLOUDOPS}}"
command: "unset GITHUB_TOKEN; JIRA_ID=$(git symbolic-ref --short HEAD | grep -e '\\b[A-Z][A-Z0-9_]\\+-[1-9][0-9]\\+' -o); TITLE=$(uv run ~/bin/get-jira-title.py ${JIRA_ID}); BODY=$(git log --date-order --pretty=format:'%C(bold yellow)%h%C(reset) %s%C(auto)%d%C(reset)%n * %b' origin/main..HEAD | grep -v Signed-off-by | sed 's/\"//g'); echo $BODY > /tmp/body.txt; gh pr create --body \"${BODY}\" --title \"${TITLE}\" --assignee @me {{.Form.DRAFT}} {{.Form.CLOUDOPS}}"
context: "global"
loadingText: "Creating pull request on GitHub"
prompts:
Expand Down
64 changes: 32 additions & 32 deletions home/encrypted_dot_work-aliases.asc
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
-----BEGIN PGP MESSAGE-----

hF4DAAAAAAAAAAASAQdA4KccKgOIhPRz2OZV+YEFdA/6/tZF3J3mUr8/1uBu6hIw
Og7elGbGcYAuzBYg/1SkPKQRHGrMEe1iegWak84JdjWJ7tIGRFh6uREk3ek1Yrip
0uoB6IB5aHGZnQF+aHXuq5R3vYs+3FsaCY2KxKK4g6KsMBwECmzheKkZU1xZvhyX
qh1XCwSEYn8KWff9erwBtXUSDIUDH9927hywhqxkNqRTJTmUJFQCy5n94ZacxjLf
1oBAs8g+86Gq6uMLZyq69hez6UU1JUin66P/J6H+vUE2nCvy5u0WFZsgQZjB8Iq3
fRnCXGGaZTCA2APNt1n/rlCniluEN2fF+8IGQiLBJLJgbxgCPd+o2ehTuuGs7o9C
SDoCfSsp6oDAhC0hQc/Ku5M7lvo5YxfQkC4zbvo7d3L2vc/YCkjdwby+o/63elqO
gkcHkWI+7k+pr+v7ptSAve5ASPvE7S0aJFO1/Y48iKoZdbdimpch6nYvJ5A8vcPn
ka4zsxdxpJa4w7z9lCNvouzSvE/lfPwqjZVNZe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Y2lSaOWKdIozaJdY64Ea37Bs8vqU
qjNfHZfoXWFAFSEI4SkjjU+HDaTYpaYbYPmpJCxYQLdwTByFBmdDOpt1oOcaQN/Y
AS0z9poLE6Wy/R7hY136myx2LCERTa103DbUen/8XCxrChYZmYIDZoqq4iQnVEx9
AfmLlnCWuCOlj6k=
=vXj9
-----END PGP MESSAGE-----

0 comments on commit b1d968a

Please sign in to comment.