-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[scripts] ,linear-tickets: list and open linear tickets
- Loading branch information
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/sh | ||
|
||
# List and open linear tickets assigned to you | ||
# https://developers.linear.app/docs | ||
# https://studio.apollographql.com/public/Linear-API/variant/current/schema/reference | ||
|
||
set -e | ||
|
||
tmpfile="/tmp/linear-tickets" | ||
|
||
if [ "$(find "$tmpfile" -mmin -10 2>/dev/null)" = "" ]; then | ||
printf "Fetching linear tickets...\r" | ||
curl -sX POST \ | ||
-H "Content-Type: application/json" \ | ||
-H "Authorization: $LINEAR_TOKEN" \ | ||
-d '{"query": "query {user(id: \"'"$LINEAR_USER_ID"'\") {id organization { urlKey } name assignedIssues {nodes {identifier state {type} title}}}}"}' \ | ||
https://api.linear.app/graphql >"$tmpfile" | ||
fi | ||
|
||
format_issues() { | ||
jq -r '.data.user.assignedIssues.nodes[]|"[\(.state.type)] \(.identifier) \(.title)"' <"$tmpfile" | ||
} | ||
|
||
urlkey="$(jq -r '.data.user.organization.urlKey' <"$tmpfile")" | ||
|
||
{ | ||
format_issues | grep -E "^\[started" | ||
format_issues | grep -E "^\[unstarted" | ||
} | ,picker -m | cut -d' ' -f2 | xargs -I{} open "https://linear.app/$urlkey/issue/{}" |