Giter Club home page Giter Club logo

git-dude's Introduction

git-dude

git-dude is a simple git desktop notifier. It monitors git repositories in current directory for new commits/branches/tags and shows desktop notification if anything new arrived.

How it works

It simply uses git fetch and parses its output to see what has changed. Then it formats new commit messages with git log and shows desktop notification with notify-send / kdialog (Linux) or growlnotify (OSX). All of this in infinite loop.

How does it look

Fedora:

git-dude on Fedora

Ubuntu:

git-dude on Ubuntu

OSX:

git-dude on Mac OSX

Haiku:

git-dude on Haiku

Requirements

On Linux:

  • notify-send on Gnome (Fedora: libnotify package, Ubuntu: libnotify-bin package)
  • kdialog on KDE (included in KDE)

On OSX:

  • growlnotify, from Growl Extras (Homebrew: growlnotify package)

Installation

$ curl -skL https://github.com/ku1ik/git-dude/raw/master/git-dude >~/bin/git-dude
$ chmod +x ~/bin/git-dude

* Make sure ~/bin is in your $PATH or put git-dude script somewhere else on your $PATH.

Homebrew

Git-dude can be installed with the following command:

$ brew install https://gist.github.com/lukaszkorecki/1289314/raw/022cd33fc366378552dc3527d72b994568644df1/git-dude.rb --HEAD

The homebrew formula lives here.

Usage

git-dude iterates over repositories that live inside the dude directory. This directory is nothing more than container for cloned repositories of projects you want to watch. Name it like you want, here for example we use ~/.git-dude:

$ mkdir ~/.git-dude
$ cd ~/.git-dude

Clone some repositories:

$ git clone --mirror https://github.com/joelthelion/autojump.git
$ git clone --mirror git://github.com/pyromaniac/hoof.git

I recommend git clone --mirror - it doesn't checkout working directory so it saves some disk space for bigger projects.

Symlinked repositories work too. This way you can monitor already cloned projects:

$ ln -s ~/code/tmuxinator .

Now run this to monitor pwd:

$ git dude

You can also pass directory name as first argument to specify which directory to monitor instead of pwd.

$ git dude ~/watched-repos

This way you can have multiple dude directories each being monitored by separate git-dude process.

Configuration

Global

Set how often git-dude should check for changes (in seconds, default: 60):

$ git config --global dude.interval 30

Set path to icon used by desktop notifications (default: none):

$ git config --global dude.icon ~/.git-dude/github_32.png

Set custom notification command ($TITLE, $DESCRIPTION and $ICON_PATH environment variables are set when invoking notification command):

$ git config --global dude.notify-command 'gntp-send "$TITLE" "$DESCRIPTION" "$ICON_PATH"'
$ git config --global dude.notify-command 'echo -e "$TITLE\n\n\n$DESCRIPTION" | espeak --stdin -k20 -ven+12'

Per-repository

Set path to icon used by desktop notifications for this repository (default: taken from global setting):

$ git config dude.icon ~/.git-dude/dm-core/datamapper.png

Tell git-dude to ignore specific repository (if you want to unmonitor it):

$ git config dude.ignore true

Custom upstream remote

When you have forked a repository you are likely to be more interested in what changes happen in the upstream repository rather than your own fork. Therefore it is possible to specify a custom remote:

$ git config dude.remote upstream

With a Git remote configuration like below, it will monitor the upstream repo instead of your fork:

$ git remote -v
origin  [email protected]:holmboe/git-dude.git (fetch)
origin  [email protected]:holmboe/git-dude.git (push)
upstream        git://github.com/ku1ik/git-dude.git (fetch)
upstream        git://github.com/ku1ik/git-dude.git (push)

Author

Marcin Kulik (https://ku1ik.com/ | @ku1ik)

git-dude's People

Contributors

00dani avatar callumj avatar danielheath avatar erjiang avatar holmboe avatar joshdick avatar kallisti5 avatar ku1ik avatar logaritmisk avatar lukaszkorecki avatar maw avatar mhor avatar rogeriopradoj avatar stelinx avatar tekdoc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

git-dude's Issues

Issue and other activity notifications

Would issue updates/mentions and the like activity notifications be within scope of this script to consider adding or accepting a pull request for? Not sure if it's possible just yet, but thought it would be nice to take that out of the realm of email and into desktop notifications like this does with commits/tags/..

Auto Merge config

There are some repositories (documentation, for instance), where I am not worried about merging, and want the latest versions with me at all times. I'm thinking of something like

git config dude.automerge = master

And this would cause the master to automatically be merged. It would be even better if git-dude could detect an unclean merge, and not do it, but (possibly) warn me about it.

need to specify .git-dude dir

Seems like I must specify the .git-dud dir on the command line,
else I get a crash because of that [-d $1] test on line 32.
Great little function otherwise :-)

KDE integration

In order to use git-dude in KDE environments you need to install colibri package, just for your information.

notifier for debian ?

Tryed several times in debian system (+openbox). Created everythink as readme says but then i enter git dude it just hangs and nothing happens. Required libraries installed. Maybe it's my fault or system ?

Running as daemon through cron (Ubuntu 15.10)

Hello. I tried adding this to my cron script so I can daemonize this git-dude:

@reboot /home/zero/.bin/git-dude 'Documents/2015-2016/Second\ Semester/CSC\ 199/Source\ Code/'

Where /home/zero/.bin/git-dude is the location of where I stored the git-dude script and the location after it is the directory with a local repo that I want to watch/observe.

Except that it doesn't work as it is supposed to do (at startup). I tried figuring it out where the fault might be, by manually calling the command in the terminal:
1.) For @reboot, it works perfectly fine with a simple echo "hi" > /home/zero/reboot.txt 2>&1 (which creates a .txt file in my Home dir)
2.) Calling the script by its location /home/zero/.bin/git-dude ..... instead of just git dude ...... Works perfectly fine with this and other test repos.
3.) Enclosing the location of the repo with quotation marks/apostrophes ' '. It works with or without.

So I was wondering where the issue might be, and why it doesn't work in cron but works if the git dude command is triggered manually.

PS. Also, any other forms of daemonizing this git dude aside from cron will be very appreciated.
Thanks in advance.

Running as a daemon (OS X)

Is it possible to run this as a daemon or is screen/tmux the best solution? (It'd be really nice if it could be added to the start up items so that it ran automagically after reboot.)

Github links

It would be cool if these notifications were linked back to github commits so we could view the commit if we were curious...

Not displaying notifications.

Thanks much for sharing this awesome tool.

I am struggling to get it to display any notifications though. This is on gnome, so its using notify-send which works fine otherwise. I am calling this script at boot to start dude:

watchdir=$(git config dude.watchdir)

if [ -n $watchdir ]; then
    git dude $watchdir  
fi

The directory where I am keeping the repos I want monitored is ~/.git-watch, which i have defined in the .gitconfig

As far as I can tell everything seems to start and run fine, as you can see in the screenshot of the relevant processes.

rofi-2018-07-29-1257-00000

I am pretty much at a loss on what could be preventing the notifications from displaying. I am not using gdm or any display manager / screensaver. Is git-dude supposed to sleep if the screensaver is active and not fetch any info from git, if I am understanding correctly?

If you have any thoughts on what could be going wrong I would love to hear them.

duplicate notification at every interval

I'm currently getting the same "new branch ss/date]" notification every 60 seconds. Whoever created this branch quickly deleted it, but the notification continues. Is this just a parsing issue?

Breaks with parenthesis in the repo name

If i have a repo with a parenthesis in the name the script breaks when running eval

icon_path=/home/grok/code/salt-states/icon.png
cd "$dir_name"; git rev-parse --git-dir 2>/dev/null
cd "$dir_name"; git config dude.ignore
basename "$dir_name" .git
git config dude.remote || true
git fetch $remote 2>&1 | grep -F -- '->' | sed 's/^ [+*=!-] //'
git config dude.icon || true
pwd
icon_path=/home/grok/code/salt-states\ (copy)/icon.png
/home/grok/bin/git-dude: eval: line 67: syntax error near unexpected token `('

Fails handling fetch results other than new branch/tag/commit

Error occurring:

fatal: ambiguous argument '+': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions

Working example of a git fetch which indicates a force-pushed branch ref in it's output:

$ git fetch
remote: Counting objects: 78, done.
remote: Compressing objects: 100% (18/18), done.
remote: Total 48 (delta 28), reused 48 (delta 28)
Unpacking objects: 100% (48/48), done.
From github.com:Username/repo
 + 83e93db...b212eee branch-name -> origin/branch-name  (forced update)

Workflow:

The output of git fetch 2>&1 | grep -F -- '->' | sed -E 's/^\s+\+\s+//' (git-dude#L71) is passed to awk (via a case statement) multiple times, each of which assigns a column of the output to a variable used by the notifier.

Piped output from working example:

$ git fetch 2>&1 | grep -F -- '->' | sed -E 's/^\s+\+\s+//'
 + 83e93db...b212eee branch-name -> origin/branch-name  (forced update)

Cause of error:

The case statement has values for new branch (git-dude#L85), new tag (git-dude#L89), and new commits (git-dude#L79). However, because ".." is also included in the output for a force-pushed branch, but not as the first column in the output, it's matched by the "new commit" case and awk assigns an output flag to the commit_range variable. For instance, if the output from the git fetch above is sent to awk (git-dude#L80) it would result in the following:

$ echo " + 83e93db...b212eee branch-name -> origin/branch-name  (forced update)" | awk '{ print $1 }'
+

In the case of a force-pushed branch, a + symbol is the first column in the output, not the abbreviated SHA-1 commit range, and thus the error. Similar issues may occur for other scenarios, such as deleted refs returned in the git fetch output which are prefixed with a - symbol.

Selective monitoring of git commits

Awesome tool. Sometimes, lots of commits take place, and it will cause screen blindness.

Here is a suggestion:
Any time a file is modified in the git repo dir and is not yet checked in or not pushed, this file's full path name is added to a "watch file"
Based on an optional parameter, use "git log --stat" instead of "git log"
Grab the files names that have changed in a commit, as output from the "git log --stat"
If they match any of the files in the "watch file", then generate the alert
When the user has committed and pushed, this file name is removed from the "watch list"

This will allow for early merge warnings.

npm package

we need a simple package for this

$ npm install -g git-dude

then

$ git-dude [options e.g. recursively watch child git repos in ~/Public] [args, e.g. pwd]

Decide on a license

The source file indicates that the license is GPLv2, but the LICENSE.txt file looks BSD-style. Which is it?

Using existing cloned repository

Hi,
I really like the idea of reusing my already cloned repository instead of cloning them again somewhere else but I was wondering how git would handle things in case of simultaneous operations, if git-dude is doing a fetch and at the same time I am doing a pull for example.

While I am pretty sure it may well never happen I would not want to corrupt a repository by accident.

Any idea if this case would be handled gracefully by git ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.