On Mon, Apr 19, 2010 at 01:19:30PM +0200, Florian Mickler wrote:
> On Sun, 18 Apr 2010 19:30:31 +0200
> Dirk Wallenstein <[email protected]> wrote:
> 
> > A full-fledged meta-git repo management tool suite would be nice. Such
> > an application would, for example, be able to:
> > - inform about the state of the modules (dirty, ahead of origin/master,
> >   not on master, etc)
> > - swap in and out personal trees. Maybe simply per symlinks.
> > - check out a particular katamari version of each module
> > 
> > Does something similar exist already? One might assume that all larger
> > projects, like for example desktop environments, could need something
> > like that. 
> > 
> 
> check out peter hutterer's git supermodule:
> 
> $> git clone git://people.freedesktop.org/~whot/X11R7.5.git
> $> cd X11R7.5
> $> git submodule init && git submodule update
> $> ./TINDERBOX /opt/xorg-7.5  
> 
> and the corresponding man-pages... :)
> 
> cheers,
> Flo

The main point was more about a meta-git - the management of the
different modules. I don't know how much effort, if any, should go into
something like that, or which users to address (the occasional tester
that may want to contribute back, or are there shared workflows of xorg
developers, etc). The thought was basically just an extension of the
overall state info need I've had.

I've hacked a script that informs me about deviations from the normal
case, which is 'HEAD == master == origin/master' , to get an
understanding of the current state. It answers "Did I edit libX11 at
some point?", "Did I insert private comments in some module while
exploring?", and such, nothing more. But you can put it in front of
`build.sh -p`  or jhbuild to catch unwanted conflicts when pulling:

./xbuild-state.py || (echo -n "continue? (*|^C)" ; read a ) && build.sh -p ...

But don't look too hard at the script. It's also not python-3 ready.

Greetings,
Dirk
#!/usr/bin/env python

################### CONFIG ########################################

XBUILD_ROOT = ""

#####################################################################

import os, sys, subprocess, re, time, shutil
from pprint import pprint as pp


DEBUG=True
strtmpl = "\x1b[1;35;40m%s\x1b[0m\n" 
def debugOut(put_it_that_way):
	if DEBUG: 
		sys.stderr.write(strtmpl % put_it_that_way)


template_for_errormessage = "\x1b[1;37;41m%s\x1b[0m\n" 
def errorOut(oh_no_you_didnt):
	sys.stderr.write(template_for_errormessage % oh_no_you_didnt)
	sys.exit( 7 )


def bash(command):
	return  subprocess.Popen(command, shell=True, stdout=subprocess.PIPE).stdout.read()


def opar():
	import optparse

	usage="%prog [options]"
	version="%prog 0.1"
	desc=""
	oparser = optparse.OptionParser(version=version, usage=usage , description=desc)

	return oparser


def changeDirToXBuildRoot():

	if len(XBUILD_ROOT):
		os.chdir( XBUILD_ROOT )
	else:
		debugOut( "No XBUILD_ROOT given. Using $PWD" )


def getCurrentBranchName():
	if os.system( '''git rev-parse --is-inside-work-tree &>/dev/null''' ) != 0 :
		errorOut( '''Not within a git work tree : %s''' % os.getcwd() )

	currentBranchName = bash( '''git describe --contains --all HEAD''' ).strip()

	if not len(currentBranchName):
		errorOut( '''Empty branch name in directory : %s''' % os.getcwd() )

	return currentBranchName


if __name__ == '__main__':

	changeDirToXBuildRoot()
	basedir = os.getcwd()

	allModules = bash( '''find -maxdepth 3 -type d -name ".git" -printf "%h\n" ''' ).strip().split('\n')

	if len(allModules) == 1 and not len(allModules[0]):
		errorOut( "Did not find any '.git' dirs below %s" % basedir )

	print "Searching for modules ahead of origin/master : " ,

	noteworthyModules = []

	currentModuleNumber = 0
	print "%5d " % len(allModules) ,

	for modulePath in allModules:

		currentModuleNumber += 1

		print "\b\b\b\b\b\b\b%5d " % ( len(allModules) - currentModuleNumber ) ,
		sys.stdout.flush()

		os.chdir( os.path.join( basedir , modulePath ) )

		# Skip if HEAD == origin/master and not dirty. The 99% case. (git-rev-parse: If not found the arg is returned)
		if os.system( '''test $(git rev-parse HEAD 2>/dev/null) = $(git rev-parse origin/master 2>/dev/null) && git diff --exit-code --quiet''' ) == 0 :
			continue

		currentBranchName = getCurrentBranchName()

		notableAttributes = []

		if os.system( '''git diff --quiet --exit-code''' ) != 0:

			notableAttributes.append( "dirty" )

		if os.system( '''git branch -r --contains HEAD | grep -q 'origin/master' ''' ) != 0:

			notableAttributes.append( "not in origin/master" )

		if currentBranchName != 'master':
			
			notableAttributes.append( "not on master" )

		noteworthyModules.append( "%s : %s (%s) %s" % ( 
					modulePath[2:] , 
					currentBranchName , 
					' ; '.join(notableAttributes) , 
					bash( '''git show --oneline -s''' ).strip() ) )

	print

	if len(noteworthyModules):
		print
		for quitter in noteworthyModules:
			print quitter
		sys.exit(1)
	
	sys.exit(0)
_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to