Skip to content

Commit 3de109d

Browse files
Matthew Rothenbergmroth
authored andcommitted
initial port from khan-dotfiles
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.
0 parents  commit 3de109d

File tree

7 files changed

+163
-0
lines changed

7 files changed

+163
-0
lines changed

.arclint

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"linters": {
3+
"khan-linter": {
4+
"type": "script-and-regex",
5+
"script-and-regex.script": "ka-lint --always-exit-0 --blacklist=yes --propose-arc-fixes",
6+
"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"
7+
}
8+
}
9+
}

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# http://editorconfig.org
2+
3+
# All rules in this file are based on our style guides:
4+
# https://github.com/Khan/style-guides
5+
6+
# This is the top-most EditorConfig file.
7+
root = true
8+
9+
[*]
10+
charset = utf-8
11+
end_of_line = lf
12+
indent_size = 4
13+
indent_style = space
14+
max_line_length = 79
15+
insert_final_newline = true

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Khan Academy
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# khan academy git-workflow
2+
3+
Collection of scripts in order to enable the [git workflow][git-at-ka]
4+
at Khan Academy. (see also: [arcanist])
5+
6+
[git-at-ka]: https://khanacademy.org/r/git-at-ka
7+
[arcanist]: https://github.com/khan/arcanist
8+
9+
## Tools
10+
11+
#### git deploy-branch
12+
Creates a remote deploy branch for use with GitHub-style deploys.
13+
14+
For GitHub-style deploys, all work must branch off a deploy branch.
15+
16+
#### git review-branch
17+
Creates a new local branch ensuring that it's not based off master.
18+
Such a branch is called a 'review branch'.
19+
20+
All review branches should be based off a deploy branch.
21+
22+
#### git recursive-grep
23+
Runs git grep recursively through submodules, showing file paths
24+
relative to cwd.

bin/git-deploy-branch

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/sh -e
2+
3+
USAGE=`cat<<EOF
4+
USAGE: git deploy-branch <branchname> [parent -- defaults to origin/master]
5+
6+
Creates a remote deploy branch for use with GitHub-style deploys.
7+
8+
For GitHub-style deploys, all work must branch off a deploy branch.
9+
See git review-branch.
10+
11+
See also Git workflow at KA:
12+
https://khanacademy.org/r/git-at-ka
13+
EOF`
14+
15+
[ -n "$1" ] || {
16+
echo "$USAGE"
17+
exit 1
18+
}
19+
20+
21+
git fetch origin
22+
if git show-ref --quiet --verify refs/remotes/origin/$1; then
23+
# The branch already exists.
24+
# Switch to it and make sure it's tracking the remote
25+
git co --track origin/$1
26+
echo "WARNING: using already existing branch origin/$1"
27+
else
28+
# Create a new branch tracking the remote one
29+
git branch --no-track $1 ${2-origin/master}
30+
git co $1
31+
git push --set-upstream origin $1
32+
fi

bin/git-recursive-grep

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
USAGE=`cat<<EOF
4+
USAGE: git recursive-grep <pattern>
5+
6+
Runs git grep recursively through submodules, showing full file paths.
7+
EOF`
8+
9+
[ -n "$1" ] || {
10+
echo "$USAGE"
11+
exit 1
12+
}
13+
14+
{
15+
git rev-parse --show-toplevel
16+
git submodule -q foreach --recursive "pwd"
17+
} | while read p; do
18+
cd "$p" && git grep --full-name "$@" | sed "s,^,$p/,"
19+
done

bin/git-review-branch

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/sh -e
2+
3+
USAGE=`cat<<EOF
4+
USAGE: git review-branch <branchname> [parent -- defaults to branch.review-parent-default]
5+
6+
Creates a new local branch ensuring that it's not based off master.
7+
This is useful as part of GitHub-style deploys. Such a branch is called
8+
a 'review branch'.
9+
10+
All review branches should be based off a deploy branch.
11+
See git deploy-branch.
12+
13+
If you've run 'git config --add branch.review-parent-default XXX',
14+
then when you run 'git review-branch foo' it will base foo off of
15+
the XXX branch. You can override this behavior via
16+
git review-branch foo other-deploy-branch
17+
18+
See also Git workflow at KA:
19+
https://khanacademy.org/r/git-at-ka
20+
EOF`
21+
22+
[ -n "$1" ] || {
23+
echo "$USAGE"
24+
exit 1
25+
}
26+
27+
28+
# If the second argument is provided, switch to it
29+
if [ -n "$2" ]; then
30+
git co $2
31+
elif [ -n "`git config --get branch.review-parent-default`" ]; then
32+
# If they have a default parent branch, switch to *that*
33+
git co "`git config --get branch.review-parent-default`"
34+
fi
35+
36+
# Stop people from landing directly to master
37+
if [ "`git rev-parse --abbrev-ref HEAD`" = "master" ]; then
38+
echo "Review branches must not be based off master";
39+
exit 1
40+
fi
41+
42+
# Apart from that check, this command just creates a local branch
43+
git co --track -b $1

0 commit comments

Comments
 (0)