Procházet zdrojové kódy

Merge commit '413353287bf396b08e9ef1dce339ef758ac59ded'

* commit '413353287bf396b08e9ef1dce339ef758ac59ded':
  fix cleanup, add better alias, week targetter for git-history-graph
  add a release-branch sync tool
  change the cleanup option to prune remotes
  add history-graph option
  use nvim by default
  Add diff helper functions
Sam Jaffe před 2 roky
rodič
revize
7ad1ff06e8
3 změnil soubory, kde provedl 44 přidání a 2 odebrání
  1. 31 1
      profile-git
  2. 4 0
      profile-linux
  3. 9 1
      profile-util

+ 31 - 1
profile-git

@@ -37,6 +37,36 @@ git-create() {
   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-cleanup='git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d'
+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)'

+ 4 - 0
profile-linux

@@ -1 +1,5 @@
 alias list="ls -lFh --color"
+
+aliasc() {
+  (alias "$1" | sed "s/^[^']*'\|'$//g") || return
+}

+ 9 - 1
profile-util

@@ -25,7 +25,7 @@ GITBRANCH() {
 }
 export PS1='$(rc=$?; echo -e "\[$CYAN\]\D{%F %T} \[$BBLUE\]\u\[$RESET\]@\[$(SUCCESS $rc)\]\h:[\w$(GITBRANCH)] $(CODE $rc)\[$RESET\]$ ")'
 
-export EDITOR=vim
+export EDITOR=nvim
 PATH="$HOME/usr/local/bin:$HOME/bin:$HOME/usr/bin:$PATH"
 export PATH
 export LC_ALL=en_US.UTF-8
@@ -190,6 +190,14 @@ repeat() {
   done
 }
 
+scriptdiff() {
+  vimdiff <("${@:3}" "$1") <("${@:3}" "$2")
+}
+
+vimdiff_jq() {
+  scriptdiff "$2" "$3" jq -M "$1"
+}
+
 if [[ $(uname) == "Darwin" ]]; then # OSX
   . ${HOME}/.profile-osx
 elif [[ $(uname) == *BSD* ]]; then # FreeBSD