-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathopenup
executable file
·65 lines (57 loc) · 2.2 KB
/
openup
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
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
## Opens a repo directory, already created using `workflow`,
## in VS Code for further work. Matches against existing
## repos by finding the provided JIRA ticket in the branch
## name (specifically: the directory name, which `workflow`
## creates based on the branch name). Does not attempt to
## rectify situations where multiple possible target repo
## directories are found: just errors out in these cases.
## To make use of the `code` command to open VSCode from the
## command line, you'll need to have followed these instructions:
##
## https://code.visualstudio.com/docs/editor/command-line#_launching-from-command-line
############################################################
## YOUR VALUES ##
#################
## Your docs workspace (i.e. where to git clone to)
## If you use a ~ in the path, don't quote the value:
WORKSPACE=~/Documents/docs_workspace
############################################################
## BEGIN SCRIPT ##
##################
## Check for provided parameter:
PARAMETER=$1
# Parse user-provided parameter and determine what to do:
if [ -z $PARAMETER ]; then
echo -e "\nERROR: No parameter provided. You must provide the JIRA ticket"
echo -e " to work on."
echo -e " Exiting ...\n"
exit;
elif [ ! -z $2 ]; then
echo -e "\nERROR: Too many parameters provided. You must provide only one"
echo -e " JIRA ticket to work on."
echo -e " Exiting ...\n"
exit;
elif [ `echo $PARAMETER | egrep -c '(^DOC-[0-9]{1,9}$)'` -lt 1 ]; then
echo -e "\nERROR: Invalid JIRA ticket format provided."
echo -e " Expecting something like DOC-1234"
echo -e " Exiting ...\n"
exit;
else
JIRA=$PARAMETER
fi
if [ `ls -l $WORKSPACE 2>/dev/null | grep -c $JIRA` -lt 1 ]; then
echo -e "\nERROR: Ticket not found in existing git repos!"
echo -e " Do you need to create a new one? Use workflow."
echo -e " Exiting ...\n"
exit;
elif [ `ls -l $WORKSPACE | grep -c $JIRA` -gt 1 ]; then
echo -e "\nERROR: Multiple matching git repos found!"
echo -e " This tool can't handle that yet. Get there manually."
echo -e " Exiting ...\n"
exit;
else
DIRNAME=`ls -d $WORKSPACE/*$JIRA*`
cd $DIRNAME
code .
fi