-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit '58c36152f6af2bce0c2144063fed00b5644139ff' as 'git-fire-…
…subtree'
- Loading branch information
Showing
3 changed files
with
146 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015 - 2016 Nimit Kalra | ||
|
||
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. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# `git-fire` :fire: | ||
|
||
### ![Inspiration](https://i.imgur.com/3POtveC.jpg) | ||
|
||
`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). | ||
|
||
**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.** | ||
|
||
- `git config --global alias.out fire` | ||
- `git config --global alias.going fire` | ||
|
||
## What It Does | ||
|
||
- changes directory to root directory of the repository | ||
- creates new branch `fire-<current branch>-<user email>-<current epoch>` | ||
- adds all files | ||
- commits with `"Fire! Branch <new branch>"` or custom message | ||
- pushes commits to remote | ||
- pushes all stashes to remote | ||
|
||
## Usage | ||
|
||
`git-fire <message>` | ||
|
||
`<message>` is optional. If not specified, `"Fire! Branch fire-<current branch>-<user email>-<current epoch>"` will be used. | ||
|
||
## Installation | ||
|
||
Just copy `git-fire` to your `$PATH` and ensure it is an executable (`chmod +x git-fire`) and you're good to go. 👍 | ||
|
||
`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`. | ||
|
||
Also make sure you have Git installed. | ||
|
||
## Credit | ||
|
||
Originally seen on [Hackathon Hackers Facebook](https://www.facebook.com/groups/hackathonhackers) group. | ||
|
||
[Original Reddit post](https://www.reddit.com/r/ProgrammerHumor/comments/3nc531/in_case_of_fire/) | ||
|
||
[Image source](https://instagram.com/p/8N8J8wRgPq/) | [Printable Image](http://imgur.com/IiAdxbB) | Artist: [Ákos Szokodi](https://github.com/szokodiakos) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#!/usr/bin/env sh | ||
|
||
# Setup. | ||
VERSION="0.0.1" | ||
|
||
version() { | ||
printf "git-fire version %s\n" "$VERSION" | ||
|
||
git --version | ||
} | ||
|
||
# Helpers. | ||
current_branch() { | ||
basename "$(git symbolic-ref HEAD)" | ||
} | ||
|
||
current_epoch() { | ||
date +%s | ||
} | ||
|
||
user_email() { | ||
git config user.email | ||
} | ||
|
||
new_branch() { | ||
echo "fire-${1:-$(current_branch)}-$(user_email)-$(current_epoch)" | ||
} | ||
|
||
fire() { | ||
initial_branch="$(current_branch)" | ||
|
||
git checkout -b "$(new_branch)" | ||
|
||
# cd to git root directory | ||
cd "$(git rev-parse --show-toplevel)" | ||
|
||
git add -A | ||
|
||
if [ -z "$1" ]; then | ||
message="Fire! Branch $(current_branch)." | ||
else | ||
message="$*" | ||
fi | ||
|
||
git commit -m "$message" --no-verify | ||
|
||
for remote in $(git remote); do | ||
git push --set-upstream "${remote}" "$(current_branch)" || true | ||
done | ||
|
||
for sha in $(git rev-list -g stash); do | ||
git push origin "$sha":refs/heads/"$(current_branch $initial_branch)"-stash-"$sha" | ||
done | ||
|
||
printf "\n\nLeave building!\n" | ||
} | ||
|
||
display_help() { | ||
cat <<-EOF | ||
usage: | ||
git fire [options] [COMMAND] [args] | ||
commands: | ||
git fire Add, commit, and push to remote in case of a fire | ||
git fire <message> Execute git fire with <message> for commit message | ||
options: | ||
-V, --version Output current version of git-fire | ||
-h, --help Display this help information | ||
EOF | ||
exit 0 | ||
} | ||
|
||
|
||
case $1 in | ||
-V|--version) version; exit 0 ;; | ||
-h|--help) display_help; exit 0 ;; | ||
esac | ||
|
||
fire "$@" |