コード例 #1
0
ファイル: MiscRepoTests.py プロジェクト: blix/pyrite
class AddTest(PyriteTestCase):
    def setUp(self):
        self.reset_test_dir()
        self.repo = Repo(location=TESTDIR)
        self.repo.init()

    def testSimpleAdd(self):
        fn_name = self.whoami()

        self.createAndAdd(fn_name)

    def testAddFromToplevel(self):
        fn_name = self.whoami()

        origwd = os.getcwd()
        os.chdir(TESTDIR)
        try:
            os.mkdir(os.path.join(TESTDIR, fn_name))
            self.createAndAdd(os.path.join(fn_name, fn_name))
        finally:
            os.chdir(origwd)

    def testAddFromSubdir(self):
        fn_name = self.whoami()

        origwd = os.getcwd()
        try:
            os.mkdir(os.path.join(TESTDIR, fn_name))
            os.chdir(os.path.join(TESTDIR, fn_name))
            self.touch(os.path.join(fn_name, fn_name))
            self.consume_output(self.repo.add_files(False, False, [fn_name]))
        finally:
            os.chdir(origwd)
コード例 #2
0
ファイル: MiscRepoTests.py プロジェクト: blix/pyrite
class LogTest(PyriteTestCase):
    def setUp(self):
        self.reset_test_dir()
        self.repo = Repo(location=TESTDIR)
        self.repo.init()

    def testLog(self):
        fn_name = self.whoami()

        self.createAndAdd(fn_name)
        self.repo.commit({Commit.SUBJECT: "test"})
        count = 0
        for commit in Commit.get_commits(self.repo, None, None):
            count += 1
        self.assertEqual(count, 1)
コード例 #3
0
ファイル: MiscRepoTests.py プロジェクト: blix/pyrite
class CommitTest(PyriteTestCase):
    def setUp(self):
        self.reset_test_dir()
        self.repo = Repo(location=TESTDIR)
        self.repo.init()

    def doSimpleCommit(self, filename):
        self.createAndAdd(filename)
        c = {Commit.SUBJECT: filename}
        self.repo.commit(c)

    def testNormalCommit(self):
        fn_name = self.whoami()

        self.doSimpleCommit(fn_name)
        c = Commit("HEAD", data=[Commit.SUBJECT], obj=self.repo)
        self.assertTrue(c)
        self.assertEquals(c.subject, fn_name)

    def testCommitCommit(self):
        fn_name = self.whoami()

        self.doSimpleCommit(fn_name)
        c = Commit.get_raw_commits(
            self.repo, None, "HEAD", 1, [Commit.SUBJECT, Commit.ID, Commit.AUTHOR, Commit.AUTHOR_DATE]
        ).next()
        self.assertTrue(c)
        auth = c[Commit.AUTHOR]
        del c[Commit.AUTHOR]
        auth_date = c[Commit.AUTHOR_DATE]
        del c[Commit.AUTHOR_DATE]
        subj = c[Commit.SUBJECT]
        c[Commit.SUBJECT] = "should not be used"

        self.createAndAdd(fn_name + "2")
        self.repo.commit(c)
        c2 = Commit.get_raw_commits(
            self.repo, None, "HEAD", 1, [Commit.SUBJECT, Commit.ID, Commit.AUTHOR, Commit.AUTHOR_DATE]
        ).next()
        self.assertEqual(auth, c2[Commit.AUTHOR])
        self.assertEqual(auth_date, c2[Commit.AUTHOR_DATE])
        self.assertEqual(subj, c2[Commit.SUBJECT])
        self.assertNotEqual(c[Commit.ID], c2[Commit.ID])
コード例 #4
0
ファイル: MiscRepoTests.py プロジェクト: blix/pyrite
 def setUp(self):
     self.reset_test_dir()
     self.repo = Repo(location=TESTDIR)
     self.repo.init()
コード例 #5
0
ファイル: MiscRepoTests.py プロジェクト: blix/pyrite
 def testInit(self):
     self.reset_test_dir()
     repo = Repo(location=TESTDIR)
     repo.init()
     self.assertTrue(repo.is_in_repo())
     self.assertEquals(repo.get_git_dir(), os.path.join(TESTDIR, ".git"))
コード例 #6
0
ファイル: collect_stats.py プロジェクト: blix/pyrite
            print 'Number of commits since %s: %d' % \
                        (t1 and t1 or 'the beginning', count)
            tot_added = tot_lost = files = 0
            for added, lost, name in repo.num_stat(t1, t2):
                tot_added += added
                tot_lost += lost
                files += 1
            print '%d files changed, %d insertions(+), %d deletions(-)' % \
                    (files, tot_added, tot_lost)
            return True
        return False

    print branch
    tag, dummy, dummy = Commit.describe_commit(repo, branch)
    if not show_changes(tag, branch):
        tag, dummy, dummy = repo.describe(branch + '^')
        show_changes(tag, branch)

    for b in others:
        show_changes(b, branch)

repo = Repo()
print_branch_stats(repo, 'master', [])
print ''
print_branch_stats(repo, 'next', ('master',))
print ''
cur_branch = repo.branch()
if cur_branch not in ('master', 'next'):
    print_branch_stats(repo, cur_branch, ('master', 'next'))
    print ''