Skip to content

Commit

Permalink
initial port from khan-dotfiles
Browse files Browse the repository at this point in the history
essentially a straight copy, with repository metadata added.

the goal here is just to have these live somewhere that makes sense
conceptually and is easy to maintain, rather than being bundled as part
of our dotfiles setup.
  • Loading branch information
Matthew Rothenberg authored and mroth committed May 26, 2015
0 parents commit 3de109d
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .arclint
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"linters": {
"khan-linter": {
"type": "script-and-regex",
"script-and-regex.script": "ka-lint --always-exit-0 --blacklist=yes --propose-arc-fixes",
"script-and-regex.regex": "\/^((?P<file>[^:]*):(?P<line>\\d+):((?P<char>\\d+):)? (?P<name>((?P<error>E)|(?P<warning>W))\\S+) (?P<message>[^\\x00]*)(\\x00(?P<original>[^\\x00]*)\\x00(?P<replacement>[^\\x00]*)\\x00)?)|(?P<ignore>SKIPPING.*)$\/m"
}
}
}
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# http://editorconfig.org

# All rules in this file are based on our style guides:
# https://github.com/Khan/style-guides

# This is the top-most EditorConfig file.
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
max_line_length = 79
insert_final_newline = true
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2015 Khan Academy

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# khan academy git-workflow

Collection of scripts in order to enable the [git workflow][git-at-ka]
at Khan Academy. (see also: [arcanist])

[git-at-ka]: https://khanacademy.org/r/git-at-ka
[arcanist]: https://github.com/khan/arcanist

## Tools

#### git deploy-branch
Creates a remote deploy branch for use with GitHub-style deploys.

For GitHub-style deploys, all work must branch off a deploy branch.

#### git review-branch
Creates a new local branch ensuring that it's not based off master.
Such a branch is called a 'review branch'.

All review branches should be based off a deploy branch.

#### git recursive-grep
Runs git grep recursively through submodules, showing file paths
relative to cwd.
32 changes: 32 additions & 0 deletions bin/git-deploy-branch
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh -e

USAGE=`cat<<EOF
USAGE: git deploy-branch <branchname> [parent -- defaults to origin/master]
Creates a remote deploy branch for use with GitHub-style deploys.
For GitHub-style deploys, all work must branch off a deploy branch.
See git review-branch.
See also Git workflow at KA:
https://khanacademy.org/r/git-at-ka
EOF`
[ -n "$1" ] || {
echo "$USAGE"
exit 1
}
git fetch origin
if git show-ref --quiet --verify refs/remotes/origin/$1; then
# The branch already exists.
# Switch to it and make sure it's tracking the remote
git co --track origin/$1
echo "WARNING: using already existing branch origin/$1"
else
# Create a new branch tracking the remote one
git branch --no-track $1 ${2-origin/master}
git co $1
git push --set-upstream origin $1
fi
19 changes: 19 additions & 0 deletions bin/git-recursive-grep
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

USAGE=`cat<<EOF
USAGE: git recursive-grep <pattern>
Runs git grep recursively through submodules, showing full file paths.
EOF`
[ -n "$1" ] || {
echo "$USAGE"
exit 1
}
{
git rev-parse --show-toplevel
git submodule -q foreach --recursive "pwd"
} | while read p; do
cd "$p" && git grep --full-name "$@" | sed "s,^,$p/,"
done
43 changes: 43 additions & 0 deletions bin/git-review-branch
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/sh -e

USAGE=`cat<<EOF
USAGE: git review-branch <branchname> [parent -- defaults to branch.review-parent-default]
Creates a new local branch ensuring that it's not based off master.
This is useful as part of GitHub-style deploys. Such a branch is called
a 'review branch'.
All review branches should be based off a deploy branch.
See git deploy-branch.
If you've run 'git config --add branch.review-parent-default XXX',
then when you run 'git review-branch foo' it will base foo off of
the XXX branch. You can override this behavior via
git review-branch foo other-deploy-branch
See also Git workflow at KA:
https://khanacademy.org/r/git-at-ka
EOF`
[ -n "$1" ] || {
echo "$USAGE"
exit 1
}
# If the second argument is provided, switch to it
if [ -n "$2" ]; then
git co $2
elif [ -n "`git config --get branch.review-parent-default`" ]; then
# If they have a default parent branch, switch to *that*
git co "`git config --get branch.review-parent-default`"
fi
# Stop people from landing directly to master
if [ "`git rev-parse --abbrev-ref HEAD`" = "master" ]; then
echo "Review branches must not be based off master";
exit 1
fi
# Apart from that check, this command just creates a local branch
git co --track -b $1

0 comments on commit 3de109d

Please sign in to comment.