Last active
August 29, 2015 14:16
-
-
Save pieman72/f8499c88d4db9041a393 to your computer and use it in GitHub Desktop.
A starter makefile with git recipes
This file contains hidden or 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
# Colorize output | |
COLORS:=$(shell tput colors 2> /dev/null) | |
ifeq ($(COLORS), 256) | |
COLOR_RESET=\033[0;39;49m | |
COLOR_BOLD=\033[1m | |
COLOR_ULINE=\033[4m | |
COLOR_BOLD_OFF=\033[0;21m | |
COLOR_ULINE_OFF=\033[0;24m | |
COLOR_NORM=\033[0;39m | |
COLOR_GREN=\033[38;5;118m | |
COLOR_BLUE=\033[38;5;81m | |
COLOR_RED=\033[38;5;161m | |
COLOR_PURP=\033[38;5;135m | |
COLOR_ORNG=\033[38;5;208m | |
COLOR_YELO=\033[38;5;227m | |
COLOR_GRAY=\033[38;5;245m | |
COLOR_WHIT=\033[38;5;15m | |
else ifeq ($(COLORS), 16) | |
COLOR_RESET=\033[0;39;49m | |
COLOR_BOLD=\033[1m | |
COLOR_ULINE=\033[4m | |
COLOR_BOLD_OFF=\033[0;21m | |
COLOR_ULINE_OFF=\033[0;24m | |
COLOR_NORM=\033[0;39m | |
COLOR_GREN=\033[0;32m | |
COLOR_BLUE=\033[0;34m | |
COLOR_RED=\033[0;31m | |
COLOR_PURP=\033[0;35m | |
COLOR_ORNG=\033[1;31m | |
COLOR_YELO=\033[0;33m | |
COLOR_GRAY=\033[1;30m | |
COLOR_WHIT=\033[1;37m | |
endif | |
.PHONY: push | |
push: commit pull | |
@echo "$(COLOR_PURP)-- Commit Prepared, Pushing to Origin --$(COLOR_RESET)" | |
@git push origin `git rev-parse --abbrev-ref HEAD` | |
@echo "[ $(COLOR_GREN)OK$(COLOR_RESET) ]\n" | |
.PHONY: pull | |
pull: | |
@echo "$(COLOR_BLUE)-- Fetching Remote Changes --$(COLOR_RESET)" | |
@git pull origin `git rev-parse --abbrev-ref HEAD` | |
@echo "[ $(COLOR_GREN)OK$(COLOR_RESET) ]\n" | |
.PHONY: commit | |
commit: clean | |
@echo "$(COLOR_ORNG)-- Showing Modified Local Files --$(COLOR_RESET)" | |
@git status | |
@echo "[ $(COLOR_GREN)OK$(COLOR_RESET) ]\n" | |
@echo "$(COLOR_YELO)-- Select File(s) To Commit (-A: all) --$(COLOR_RESET)" | |
@read -p "Files: " COMMIT_LIST;\ | |
if [ -n "$$COMMIT_LIST" ]; then\ | |
git add $$COMMIT_LIST;\ | |
echo "[ $(COLOR_GREN)OK$(COLOR_RESET) ]\n";\ | |
echo "$(COLOR_GREN)-- Files Chosen, Add Message --$(COLOR_RESET)";\ | |
git commit;\ | |
else\ | |
echo "$(COLOR_GREN)-- Nothing committed just now --$(COLOR_RESET)";\ | |
fi; | |
@echo "[ $(COLOR_GREN)OK$(COLOR_RESET) ]\n" | |
.PHONY: diff | |
diff: clean | |
@echo "$(COLOR_ORNG)-- Showing Local Diff --$(COLOR_RESET)" | |
@git diff | /usr/share/vim/vim74/macros/less.sh | |
@echo "[ $(COLOR_GREN)OK$(COLOR_RESET) ]\n" | |
.PHONY: merge | |
merge: clean | |
@echo "$(COLOR_ORNG)-- Merging Current Branch Into Master --$(COLOR_RESET)" | |
@CURRENT_BRANCH=`git rev-parse --abbrev-ref HEAD`;\ | |
if [ $$CURRENT_BRANCH = 'master' ]; then\ | |
echo "Already working on $(COLOR_RED)master$(COLOR_RESET)";\ | |
return 1;\ | |
fi;\ | |
git checkout master;\ | |
git merge $$CURRENT_BRANCH;\ | |
git push origin --delete $$CURRENT_BRANCH\ | |
echo "'$(COLOR_BLUE)$$CURRENT_BRANCH$(COLOR_RESET)' merged successfully!" | |
@echo "[ $(COLOR_GREN)OK$(COLOR_RESET) ]\n" | |
.PHONY: branch | |
branch: clean | |
@echo "$(COLOR_ORNG)-- Create a New Branch --$(COLOR_RESET)" | |
@echo 'Current branch:$(COLOR_BLUE)' `git rev-parse --abbrev-ref HEAD`\ | |
'$(COLOR_RESET)' | sed 's/master/$(COLOR_RED)master/' | |
@read -p "New branch name: " BRANCH_NAME;\ | |
git checkout -b $$BRANCH_NAME;\ | |
echo "Now using: '$(COLOR_BLUE)$$BRANCH_NAME$(COLOR_RESET)'" | |
@echo "[ $(COLOR_GREN)OK$(COLOR_RESET) ]\n" | |
.PHONY: clean | |
clean: | |
@echo "$(COLOR_RED)-- Cleaning Up --$(COLOR_RESET)" | |
@rm poop.* | |
@echo "[ $(COLOR_GREN)OK$(COLOR_RESET) ]\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment