Adrian Schröter
e7fbd5920f
Mon Feb 13 15:52:19 GMT 2012 - aspiers@suse.com Add test suite and fix two bugs it found: 1. --subdir was not working 2. --scm bzr was not working FWIW it also works on SLE11 now. I will issue a separate request for my enhancements to tar_scm, since they are much more intrusive (but have about 90% test coverage). OBS-URL: https://build.opensuse.org/request/show/105040 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-tar_scm?expand=0&rev=32
49 lines
1.3 KiB
Python
49 lines
1.3 KiB
Python
#!/usr/bin/python
|
|
|
|
import os
|
|
|
|
from fixtures import Fixtures
|
|
from utils import mkfreshdir, run_git
|
|
|
|
class GitFixtures(Fixtures):
|
|
def init(self):
|
|
self.create_repo()
|
|
|
|
self.timestamps = { }
|
|
self.sha1s = { }
|
|
|
|
self.create_commits(2)
|
|
|
|
def run(self, cmd):
|
|
return run_git(self.repo_path, cmd)
|
|
|
|
def create_repo(self):
|
|
os.makedirs(self.repo_path)
|
|
os.chdir(self.repo_path)
|
|
self.run('init')
|
|
self.run('config user.name test')
|
|
self.run('config user.email test@test.com')
|
|
self.wd = self.repo_path
|
|
print "created repo", self.repo_path
|
|
|
|
def do_commit(self, newly_created):
|
|
self.run('add .')
|
|
self.run('commit -m%d' % self.next_commit_rev)
|
|
|
|
def get_metadata(self, formatstr):
|
|
return self.run('log -n1 --pretty=format:"%s"' % formatstr)[0]
|
|
|
|
def record_rev(self, rev_num):
|
|
tag = 'tag' + str(rev_num)
|
|
self.run('tag ' + tag)
|
|
self.revs[rev_num] = tag
|
|
self.timestamps[tag] = self.get_metadata('%at')
|
|
self.sha1s[tag] = self.get_metadata('%h')
|
|
self.scmlogs.annotate(
|
|
"Recorded rev %d: id %s, timestamp %s, SHA1 %s" % \
|
|
(rev_num,
|
|
tag,
|
|
self.timestamps[tag],
|
|
self.sha1s[tag])
|
|
)
|