Skip to content

Instantly share code, notes, and snippets.

@phelrine
Created October 19, 2011 07:48
Show Gist options
  • Save phelrine/1297701 to your computer and use it in GitHub Desktop.
Save phelrine/1297701 to your computer and use it in GitHub Desktop.
repository update notifier
#!/bin/sh
## usage
# sh notify.sh REPOSITORY_PATH FORMAT_STRING
TWEET_PROGRAM="ruby tweet.rb"
pushd `dirname $0`
# update repository
cd $1
git fetch
commit_count=`git rev-list master..origin | wc -l`
git stash
git merge origin/master > /dev/null 2>&1
# return scripts dir
popd
# tweet
${TWEET_PROGRAM} "$(printf "$2" $commit_count)"
# -*- coding: utf-8 -*-
require 'rubytter'
require 'oauth'
CONSUMER_TOKEN, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_SECRET = File.open("consumer").read.split
client = OAuthRubytter.new(
OAuth::AccessToken.new(
OAuth::Consumer.new(CONSUMER_TOKEN, CONSUMER_SECRET, :site => "https://api.twitter.com/"),
ACCESS_TOKEN,
ACCESS_SECRET
)
)
client.update ARGV[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment