Skip to content

Commit 97f9a41

Browse files
author
Martin Meredith
committed
Merge commit '58c36152f6af2bce0c2144063fed00b5644139ff' as 'git-fire-subtree'
2 parents ca3a91f + 58c3615 commit 97f9a41

File tree

3 files changed

+146
-0
lines changed

3 files changed

+146
-0
lines changed

git-fire-subtree/LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 - 2016 Nimit Kalra
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.
22+

git-fire-subtree/README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# `git-fire` :fire:
2+
3+
### ![Inspiration](https://i.imgur.com/3POtveC.jpg)
4+
5+
`git-fire` is a Git plugin that **helps in the event of an emergency** by switching to the repository's root directory, adding all current files, committing, and pushing commits and all stashes to a new branch (to prevent merge conflicts).
6+
7+
**Alias it to [`git out`](https://np.reddit.com/r/ProgrammerHumor/comments/3nc531/in_case_of_fire/cvmxnv1) or [`git going`](https://np.reddit.com/r/ProgrammerHumor/comments/3nc531/in_case_of_fire/cvmsajb) for comedic effect.**
8+
9+
- `git config --global alias.out fire`
10+
- `git config --global alias.going fire`
11+
12+
## What It Does
13+
14+
- changes directory to root directory of the repository
15+
- creates new branch `fire-<current branch>-<user email>-<current epoch>`
16+
- adds all files
17+
- commits with `"Fire! Branch <new branch>"` or custom message
18+
- pushes commits to remote
19+
- pushes all stashes to remote
20+
21+
## Usage
22+
23+
`git-fire <message>`
24+
25+
`<message>` is optional. If not specified, `"Fire! Branch fire-<current branch>-<user email>-<current epoch>"` will be used.
26+
27+
## Installation
28+
29+
Just copy `git-fire` to your `$PATH` and ensure it is an executable (`chmod +x git-fire`) and you're good to go. 👍
30+
31+
`git-fire` is also installable via [NPM](https://npmjs.com/git-fire). Just run `npm install -g git-fire`, which will copy the `git-fire` binary to your `$PATH`.
32+
33+
Also make sure you have Git installed.
34+
35+
## Credit
36+
37+
Originally seen on [Hackathon Hackers Facebook](https://www.facebook.com/groups/hackathonhackers) group.
38+
39+
[Original Reddit post](https://www.reddit.com/r/ProgrammerHumor/comments/3nc531/in_case_of_fire/)
40+
41+
[Image source](https://instagram.com/p/8N8J8wRgPq/) | [Printable Image](http://imgur.com/IiAdxbB) | Artist: [Ákos Szokodi](https://github.com/szokodiakos)

git-fire-subtree/git-fire

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#!/usr/bin/env sh
2+
3+
# Setup.
4+
VERSION="0.0.1"
5+
6+
version() {
7+
printf "git-fire version %s\n" "$VERSION"
8+
9+
git --version
10+
}
11+
12+
# Helpers.
13+
current_branch() {
14+
basename "$(git symbolic-ref HEAD)"
15+
}
16+
17+
current_epoch() {
18+
date +%s
19+
}
20+
21+
user_email() {
22+
git config user.email
23+
}
24+
25+
new_branch() {
26+
echo "fire-${1:-$(current_branch)}-$(user_email)-$(current_epoch)"
27+
}
28+
29+
fire() {
30+
initial_branch="$(current_branch)"
31+
32+
git checkout -b "$(new_branch)"
33+
34+
# cd to git root directory
35+
cd "$(git rev-parse --show-toplevel)"
36+
37+
git add -A
38+
39+
if [ -z "$1" ]; then
40+
message="Fire! Branch $(current_branch)."
41+
else
42+
message="$*"
43+
fi
44+
45+
git commit -m "$message" --no-verify
46+
47+
for remote in $(git remote); do
48+
git push --set-upstream "${remote}" "$(current_branch)" || true
49+
done
50+
51+
for sha in $(git rev-list -g stash); do
52+
git push origin "$sha":refs/heads/"$(current_branch $initial_branch)"-stash-"$sha"
53+
done
54+
55+
printf "\n\nLeave building!\n"
56+
}
57+
58+
display_help() {
59+
cat <<-EOF
60+
61+
usage:
62+
git fire [options] [COMMAND] [args]
63+
64+
commands:
65+
git fire Add, commit, and push to remote in case of a fire
66+
git fire <message> Execute git fire with <message> for commit message
67+
68+
69+
options:
70+
-V, --version Output current version of git-fire
71+
-h, --help Display this help information
72+
73+
EOF
74+
exit 0
75+
}
76+
77+
78+
case $1 in
79+
-V|--version) version; exit 0 ;;
80+
-h|--help) display_help; exit 0 ;;
81+
esac
82+
83+
fire "$@"

0 commit comments

Comments
 (0)