From 06aee87c07bf6ac2ae890de470bfa85fd24be452 Mon Sep 17 00:00:00 2001 From: Sverre Rabbelier Date: Thu, 19 Jun 2008 00:24:21 +0200 Subject: [PATCH] gitstats: Extended setupRepo to create the repo as specified in metrics.txt With this new repo in place experimenting can begin with defining a 'belongs to' metric. The tree may have to be expanded later to include a more complicated structure. --- src/scripts/setupRepo.py | 85 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 79 insertions(+), 6 deletions(-) diff --git a/src/scripts/setupRepo.py b/src/scripts/setupRepo.py index dc96f99..9508638 100755 --- a/src/scripts/setupRepo.py +++ b/src/scripts/setupRepo.py @@ -155,20 +155,20 @@ def createLinearHistory(filename, createFile=False, initialCommit=False, start=1 # And a final commit git.commit("-a", "-m", "Last commit") -def createBranch(name, checkoutBranch=True): +def createBranch(name, checkout=True): """Creates a branch with the specified name and optionally checks it out Params: name: The name of the new branch. - checkoutBranch: Whether to perform a checkout of the branch. + checkout: Whether to perform a checkout of the branch. """ git = Git(".") git.branch(name) - if checkoutBranch: - git.checkout(name) + if checkout: + checkoutBranch(name) def createDir(name, changeDir=False): """Creates a directory with the specified name @@ -190,6 +190,15 @@ def checkoutBranch(name): git.checkout(name) +def checkoutRelease(release): + """Switches to the specified release + + Params: + release: The release to check out + """ + + checkoutBranch('v' + str(release)) + def mergeBranch(name): """Merges the current branch with the specified branch @@ -297,7 +306,7 @@ def createTestRepository(): createLinearHistory(c, createFile=True, initialCommit=True, finalCommit=True) # Create a maintenance branch - createBranch(mt, True) + createBranch(mt) # Create some history there too createLinearHistory(n, createFile=True, count=3) @@ -383,7 +392,71 @@ def createMetricsRepository(): """Creates a metrics repository in setupRepo.metricspath """ - pass + # files + c = "content.txt" + n = "notes.txt" + r = "README" + + # branches + m = "master" + mt = "maint" + h = "help" + + # Create a repository to work in + setupRepo(metricsPath) + + # Set the info + setDefaultInfo() + + # And create some history + createLinearHistory(c, createFile=True, count=2) + + # Mark this commit so that we can jump back to it later + tagRelease(1) + + # And create some more history + createLinearHistory(c, start=3, count=3) + + # Go back to that marked commit + checkoutRelease(1) + + # Now create a new branch to work on + createBranch(mt) + + # Fix us up some more history + createLinearHistory(n, createFile=True, count=2) + + # Mark this commit too so we can jump back + tagRelease(2) + + # And make some more history + createLinearHistory(n, start=2, count=1) + + # Now merge this back into master + checkoutBranch(m) + mergeBranch(mt) + + # Go back to maint to create some more there + checkoutBranch(mt) + createLinearHistory(n, start=3, count=1) + + # Now let's go back and fix that one commit + checkoutRelease(2) + createBranch(h) + createLinearHistory(r, createFile=True, count=1) + + # Go back to maint, and merge it in + checkoutBranch(mt) + mergeBranch(h) + + # Now we can create the last bit of history here + createLinearHistory(n, start=4, count=3) + + # Now we can create our last bit of history on master + checkoutBranch(m) + createLinearHistory(c, start=6, count=3) + + return 0 def main(args): """Creates a test and a metrics repository -- 2.11.4.GIT