Permalink
Browse files

Added two scripts to make checking the git repositories easier.

  • Loading branch information...
1 parent 08d60c2 commit cb0b38c730394a40229e457078aa4a651683cd5e @markvl markvl committed Apr 30, 2009
Showing with 89 additions and 0 deletions.
  1. +22 −0 README.txt
  2. +48 −0 git-svn-check-unpushed
  3. +19 −0 git-svn-externals-check
View
@@ -28,3 +28,25 @@ Enjoy,
- Andre Pang <ozone@algorithm.com.au>
+
+git-svn-check-unpushed and git-svn-externals-check
+==================================================
+
+In addition to the git-svn-clone-externals script I added two more
+scripts:
+
+* ``git-svn-check-unpushed`` tries to determine whether there are
+ commits which are not yet pushed back to the subversion
+ repository. I took this idea from Magit (an interface to the version
+ control system Git, implemented as an extension to Emacs) and
+ implemented it in Python instead of Lisp.x
+
+* git-svn-externals-check is a script that displays whether there are
+ uncommitted changes or commits that are not pushed to the subversion
+ repository yet. Basically it executes ``git status`` and the
+ ``git-svn-check-unpushed`` scripts for each directory in the current
+ directory.
+
+Feel free to use and improve these scripts.
+
+- Mark van Lent <mark@vlent.nl>
View
@@ -0,0 +1,48 @@
+#!/usr/bin/python
+
+from commands import getoutput
+import sys
+import logging
+
+logger = logging.getLogger()
+console = logging.StreamHandler()
+formatter = logging.Formatter('%(levelname)-8s %(message)s')
+console.setFormatter(formatter)
+logger.addHandler(console)
+logger.level = logging.INFO
+
+
+def find_svn_branch_name():
+ interesting_branches = ['remotes/git-svn',
+ 'remotes/trunk',
+ 'trunk']
+
+ gitbranch = getoutput('git branch -a | cut -c3-')
+
+ branches = gitbranch.split('\n')
+ for branch in interesting_branches:
+ if branch in branches:
+ return branch
+
+
+def find_uncommitted(svn_branch):
+ output = getoutput('git log --pretty="format:%%h %%s" %s..HEAD' %
+ svn_branch)
+ if output:
+ print 'Possible unpushed commits:'
+ print output
+ else:
+ print 'No unpushed commits found.'
+
+
+if __name__ == '__main__':
+ status = getoutput('git status')
+ if status.startswith('fatal'):
+ print status
+ sys.exit(1)
+ svn_branch = find_svn_branch_name()
+ if svn_branch is None:
+ print "No svn branch found"
+ sys.exit(1)
+ logger.debug('Found branch: %s', svn_branch)
+ find_uncommitted(svn_branch)
View
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+for dir in *; do
+ if [ -d $dir ]; then
+ cd $dir
+ STATUS=$(git status)
+ UNPUSHED=$(git-svn-check-unpushed)
+ if [ $(echo $STATUS|grep -c "clean") -lt 1 -o \
+ $(echo $UNPUSHED|grep -c "No unpushed") -lt 1 ]; then
+ echo '>>>>>>>>>>>>>>>>' $dir '<<<<<<<<<<<<<<<<'
+ git status
+ git-svn-check-unpushed
+ echo '----------------------------------------'
+ else
+ echo $dir 'is clean'
+ fi
+ cd ..
+ fi
+done

0 comments on commit cb0b38c

Please sign in to comment.