| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- git-ignore() {
- local site="https://raw.githubusercontent.com/github/gitignore/master"
- if [[ $1 == "--global" ]]; then
- shift
- ignore_file=${HOME}/.gitignore_global
- site+="/Global"
- else
- ignore_file="./.gitignore"
- fi
- echo "## ${1}.gitignore" >> "${ignore_file}"
- wget -qO- "${site}/${1}.gitignore" >> "${ignore_file}"
- }
- git-inject-clang-format() {
- local fromdir todir
- fromdir=${HOME}/.dotfiles/resources
- todir=.git/hooks
- mkdir -p "${todir}/pre-commit.d"
- git config hooks.clangformat.style file
- cp ${fromdir}/clang-format.template ./.clang-format
- cp ${fromdir}/pre-commit-all.hook ${todir}/pre-commit
- cp ${fromdir}/clang-format.hook ${todir}/pre-commit.d/clang-format
- }
- git-create() {
- mkcd "${1}"; shift
- git init
- echo '## User Defined Gitignore' > .gitignore
- local message="Initializing repository"
- if [[ $# -ge 1 ]]; then
- for i in "$@"; do git-ignore "${i}"; done
- message+=" with ignore lists: [ $1"
- [[ $# -eq 1 ]] || message+="$(printf ", %s" "${@:2}")"
- message+=" ]"
- fi
- maybe_do git-ignore-local
- git add .gitignore
- git commit -m "${message}"
- }
- git-sync-release() {
- rel="release/${1}"
- br="$(git branch | grep '^\*' | cut -c3-)"
- # Confirm that this is a real branch
- (git branch -r | grep "${rel}" &>/dev/null) || return 1
- # Merge dev
- # Make sure that we're not doing a weird clobber
- git checkout "${rel}" || return 2
- # Sanity check...
- git pull
- git merge --ff-only origin/dev || return 3
- # Update origin:release
- git push
- git checkout "${br}"
- # Don't delete if we're on this branch
- [[ "${br}" == "${rel}" ]] || git branch -D "${rel}"
- }
- alias git-graph="git log --graph --pretty=oneline --abbrev-commit --decorate --all"
- alias git-history-graph="git log --graph --pretty='format:%C(auto)%h (%<(50,trunc)%s, %ad)%d' --abbrev-commit --decorate --all"
- git-weeks-ago() {
- weeks="${1:-1}"
- end="$(date +"%Y-%m-%d" --date="${weeks} weeks ago Sunday")"
- begin="$(date +"%Y-%m-%d" --date="$((weeks+1)) weeks ago Sunday")"
- echo "--after ${begin} --before ${end}"
- }
- alias git-cleanup='(git branch --merged | egrep -v "(^\*|^\+|master|dev)" | xargs git branch -d); (git fetch --prune 2>&1 | grep deleted | sed "s/.*-> origin\///" | xargs git branch -D)'
|