Skip to content

Instantly share code, notes, and snippets.

@drewbrokke
Last active February 13, 2020 17:30
Show Gist options
  • Save drewbrokke/87e48878473066a80a365bc8e83abbf4 to your computer and use it in GitHub Desktop.
Save drewbrokke/87e48878473066a80a365bc8e83abbf4 to your computer and use it in GitHub Desktop.
My `jack-cli` configuration
{
"$schema": "./.schema.jack.json",
"blacklistPatterns": [],
"commands": [
{
"command": "git -p diff [%SHA_RANGE%] --name-only | less",
"description": "View changed file names",
"foreground": true,
"key": "l"
},
{
"command": "time_machine [%SHA_SINGLE%]",
"description": "Open changed files as they were at that commit",
"foreground": false,
"key": "S-o"
},
{
"command": "git difftool [%SHA_RANGE%]",
"description": "Open total diff in difftool",
"key": "t"
},
{
"command": "git cherry-pick [%SHA_SINGLE_OR_RANGE%]",
"description": "Cherry-pick commits",
"key": "S-c",
"onErrorCommand": "git cherry-pick --abort"
},
{
"command": "git -p dsf [%SHA_RANGE%] --patch --stat-width=1000 --ignore-all-space",
"description": "View total diff (custom)",
"foreground": true,
"key": "d"
},
{
"command": "git -p dsf [%SHA_RANGE%] --patch --stat-width=1000 --ignore-all-space",
"description": "View total diff (custom)",
"foreground": true,
"key": "d"
},
{
"command": "git -p diff [%SHA_RANGE%] --name-only | sed -f $HOME/Documents/sed_commands/show_modules.txt | sort -u | less",
"description": "View changed modules",
"foreground": true,
"key": "S-m"
},
{
"command": "ji [%COMMIT_MESSAGE%]",
"description": "Open Jira ticket in browser",
"key": "i"
},
{
"command": "getpr [%COMMIT_MESSAGE%]",
"description": "Open Github PR in browser",
"key": "p"
},
{
"command": "git format-patch -o $HOME/Desktop/patches [%SHA_RANGE%]",
"description": "Export commits as patch files",
"key": "S-p"
},
{
"command": "git revert [%SHA_SINGLE_OR_RANGE%]",
"description": "Revert commit",
"key": "S-r",
"onErrorCommand": "git cherry-pick --abort",
"refreshOnComplete": true
},
{
"command": "git commit --fixup=[%SHA_SINGLE%]",
"description": "Fix up commit with index.",
"foreground": true,
"key": "S-f",
"refreshOnComplete": true
},
{
"command": "git rebase -i --autosquash [%SHA_SINGLE%]^",
"description": "Perform interactive rebase",
"foreground": true,
"key": "S-i",
"onErrorCommand": "git rebase --abort",
"refreshOnComplete": true
},
{
"command": "gitk [%SHA_SINGLE_OR_RANGE%]",
"description": "Open gitk",
"foreground": true,
"key": "w"
}
],
"gitShowOptions": "--patch-with-stat --stat-width 1000 --color --ignore-all-space",
"notificationTimeout": 3000,
"searchIndexLimit": 10000,
"showLineNumbers": true,
"useLegacyEscapeKeyBehavior": false,
"useSearchIndex": true
}
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"blacklistPatterns": {
"type": "array",
"items": {
"type": "string"
}
},
"commands":{
"type": "array",
"items": {
"type": "object",
"properties": {
"command": {
"type": "string"
},
"description": {
"type": "string"
},
"foreground": {
"type": "boolean",
"default": false
},
"key": {
"type": "string",
"pattern": "^([CS]-)?[a-z]$"
},
"onErrorCommand": {
"type": "string",
"default": null
},
"refreshOnComplete": {
"type": "boolean",
"default": false
}
},
"required": [
"command",
"description",
"key"
]
}
},
"gitShowOptions": {
"type": "string"
},
"notificationTimeout": {
"type": "number"
},
"searchIndexLimit": {
"type": "number"
},
"showLineNumbers": {
"type": "boolean"
},
"useLegacyEscapeKeyBehavior": {
"type": "boolean"
},
"useSearchIndex": {
"type": "boolean"
}
}
}
#!/bin/bash
# Requires 'jq'
exitwithmessage() {
echo "$1" && exit "$2"
}
OPT_PRINT=0
while getopts "p" FLAGS; do
case $FLAGS in
p) OPT_PRINT=1 ;;
esac
done
shift $((OPTIND - 1))
TICKET="$(grep -oE "\\w[A-Z]+-\\d+" <<<"$1")"
test -n "${TICKET}" || TICKET="$(git rev-parse --abbrev-ref HEAD 2>/dev/null | grep -oE "\\w[A-Z]+-\\d+")"
test -n "${TICKET}" || read -rp "Please enter a JIRA ticket number: " TICKET
TICKET_URL="https://issues.liferay.com/rest/api/latest/issue/${TICKET}"
HEADERS="$(curl -sI "${TICKET_URL}")"
BODY="$(curl -s "${TICKET_URL}")"
STATUS="$(echo "${HEADERS}" | grep "HTTP/1.1" | cut -d' ' -f 2)"
test "${STATUS}" == "404" && exitwithmessage "No page found for \"${TICKET_URL}\"" 1
PR_URL="$(echo "${BODY}" | jq -rM '.fields.customfield_10421')"
echo "${PR_URL}"
test "${PR_URL}" == null && exitwithmessage "No pull request found for ${TICKET}" 1
if [ "${OPT_PRINT}" -gt 0 ]; then
exitwithmessage "${PR_URL}" 0
else
open "${PR_URL}"
fi
#!/bin/bash
MESSAGE="$1"
if [ "$MESSAGE" ]; then
# Get the ticket number from the given message
NUMBER="$(grep -oE "[A-Z]+-\d+" <<<"$MESSAGE")"
if [ ! "$NUMBER" ]; then
NUMBER="LPS-$(grep -oE "\d+" <<<"$MESSAGE")"
fi
else
# Get the ticket numbe from the latest commit's message
NUMBER="$(git rev-parse --abbrev-ref HEAD | grep -oE "[A-Z]+-\\d+")"
fi
open "http://issues.liferay.com/browse/$NUMBER"
s,/src/.*,,
s,/test/.*,,
s,/documentation/.*,,
s,/build.gradle,,
s,/bnd.bnd,,
s,/.*.markdown,,
s,/.*.sql,,
s,/.lfrbuild-portal,,
/^modules$/d
#!/bin/bash
SHA="${1:?Make sure to give me a SHA}"
temp_dir=$(mktemp -d)
# repo_root=$(git rev-parse --show-toplevel)
for i in $(git show "$SHA" --name-only --pretty='')
do
git show "$SHA:$i" > "$temp_dir/${i##*/}"
done
find "$temp_dir" -type f -exec subl {} \;
rm -rf "$temp_dir"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment