Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 72 lines (62 sloc) 2.212 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
#!/bin/bash
#
# git-dude - Git commit notifier
# https://github.com/sickill/git-dude
#
# Copyright (C) 2011 Marcin Kulik <http://ku1ik.com/>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# Distributed under the GNU General Public License, version 2.0.

interval=$(git config dude.interval)
interval=${interval:-60}

icon_path=$(git config dude.icon)
icon_path=${icon_path:-`pwd`/icon.png}
eval icon_path=$icon_path # to expand ~

export LC_ALL=C # make sure git talks english

[[ -d $1 ]] && cd $1

function notify() {
  if [ $(which notify-send 2>/dev/null) ]; then
    notify-send -i "$1" "$2" "$3"
  elif [ $(which growlnotify 2>/dev/null) ]; then
    growlnotify --image "$1" -m "$3" "$2"
  else
    echo $2; echo $3
  fi
}

while true; do
  for dir_name in *; do
    if [[ -d $dir_name ]]; then
      repo_name=$(basename $dir_name .git)
      cd $dir_name

      changes=$(git fetch -v 2>&1 | grep -F -- '->')

      while read -r line; do
        case $line in
          *..*)
            commit_range=$(echo "$line" | awk '{ print $1 }')
            branch_name=$(echo "$line" | awk '{ print $2 }')
            commit_messages=$(git log $commit_range --pretty=format:'%s (%an)')
            notify $icon_path "New commits in $repo_name/$branch_name" "$commit_messages"
            ;;
          *new*)
            branch_name=$(echo "$line" | awk '{ print $4 }')
            notify $icon_path "New branch $repo_name/$branch_name"
            ;;
        esac
      done <<< "$changes"

      cd - &>/dev/null
    fi
  done

  sleep $interval
done
Something went wrong with that request. Please try again.