generated from ddev/ddev-addon-template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathopen-issue
executable file
·45 lines (39 loc) · 1.17 KB
/
open-issue
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
#!/usr/bin/env bash
#ddev-generated
## Description: Quickly open the current issue you are working on
## Usage: open-issue
## Example: "ddev open-issue"
## Installed globally
# Get the name of the active Git branch
branch_name=$(git rev-parse --abbrev-ref HEAD)
# Extract the task ID using regex
if [[ $branch_name =~ T-([0-9]+) ]]; then
task_id="${BASH_REMATCH[1]}"
result="https://projects.annertech.com/app/tasks/$task_id"
# Copy to clipboard based on OS
if command -v xclip &> /dev/null; then
echo "$result" | xclip -selection clipboard
echo "Copied to clipboard: $result"
elif command -v pbcopy &> /dev/null; then
echo "$result" | pbcopy
echo "Copied to clipboard: $result"
else
echo "Clipboard command not found. Please install xclip (Linux) or use pbcopy (macOS)."
# Display the result for manual copying
printf "$result"
printf "\n\n"
fi
case $OSTYPE in
linux-gnu)
xdg-open ${result}
;;
"darwin"*)
open ${result}
;;
"win*"* | "msys"*)
start ${result}
;;
esac
else
echo "No task ID found in the branch name."
fi