def test_new_commit(): with no_lingering_errors(): with test_tempdir(b'bup-tgit-') as tmpdir: environ[b'BUP_DIR'] = bupdir = tmpdir + b'/bup' git.init_repo(bupdir) git.verbose = 1 w = git.PackWriter() tree = os.urandom(20) parent = os.urandom(20) author_name = b'Author' author_mail = b'author@somewhere' adate_sec = 1439657836 cdate_sec = adate_sec + 1 committer_name = b'Committer' committer_mail = b'committer@somewhere' adate_tz_sec = cdate_tz_sec = None commit = w.new_commit(tree, parent, b'%s <%s>' % (author_name, author_mail), adate_sec, adate_tz_sec, b'%s <%s>' % (committer_name, committer_mail), cdate_sec, cdate_tz_sec, b'There is a small mailbox here') adate_tz_sec = -60 * 60 cdate_tz_sec = 120 * 60 commit_off = w.new_commit(tree, parent, b'%s <%s>' % (author_name, author_mail), adate_sec, adate_tz_sec, b'%s <%s>' % (committer_name, committer_mail), cdate_sec, cdate_tz_sec, b'There is a small mailbox here') w.close() commit_items = git.get_commit_items(hexlify(commit), git.cp()) local_author_offset = localtime(adate_sec).tm_gmtoff local_committer_offset = localtime(cdate_sec).tm_gmtoff WVPASSEQ(tree, unhexlify(commit_items.tree)) WVPASSEQ(1, len(commit_items.parents)) WVPASSEQ(parent, unhexlify(commit_items.parents[0])) WVPASSEQ(author_name, commit_items.author_name) WVPASSEQ(author_mail, commit_items.author_mail) WVPASSEQ(adate_sec, commit_items.author_sec) WVPASSEQ(local_author_offset, commit_items.author_offset) WVPASSEQ(committer_name, commit_items.committer_name) WVPASSEQ(committer_mail, commit_items.committer_mail) WVPASSEQ(cdate_sec, commit_items.committer_sec) WVPASSEQ(local_committer_offset, commit_items.committer_offset) commit_items = git.get_commit_items(hexlify(commit_off), git.cp()) WVPASSEQ(tree, unhexlify(commit_items.tree)) WVPASSEQ(1, len(commit_items.parents)) WVPASSEQ(parent, unhexlify(commit_items.parents[0])) WVPASSEQ(author_name, commit_items.author_name) WVPASSEQ(author_mail, commit_items.author_mail) WVPASSEQ(adate_sec, commit_items.author_sec) WVPASSEQ(adate_tz_sec, commit_items.author_offset) WVPASSEQ(committer_name, commit_items.committer_name) WVPASSEQ(committer_mail, commit_items.committer_mail) WVPASSEQ(cdate_sec, commit_items.committer_sec) WVPASSEQ(cdate_tz_sec, commit_items.committer_offset)
def test_new_commit(): with no_lingering_errors(), test_tempdir('bup-tgit-') as tmpdir: os.environ['BUP_MAIN_EXE'] = bup_exe os.environ['BUP_DIR'] = bupdir = tmpdir + "/bup" git.init_repo(bupdir) git.verbose = 1 w = git.PackWriter() tree = os.urandom(20) parent = os.urandom(20) author_name = 'Author' author_mail = 'author@somewhere' adate_sec = 1439657836 cdate_sec = adate_sec + 1 committer_name = 'Committer' committer_mail = 'committer@somewhere' adate_tz_sec = cdate_tz_sec = None commit = w.new_commit(tree, parent, '%s <%s>' % (author_name, author_mail), adate_sec, adate_tz_sec, '%s <%s>' % (committer_name, committer_mail), cdate_sec, cdate_tz_sec, 'There is a small mailbox here') adate_tz_sec = -60 * 60 cdate_tz_sec = 120 * 60 commit_off = w.new_commit(tree, parent, '%s <%s>' % (author_name, author_mail), adate_sec, adate_tz_sec, '%s <%s>' % (committer_name, committer_mail), cdate_sec, cdate_tz_sec, 'There is a small mailbox here') w.close() commit_items = git.get_commit_items(commit.encode('hex'), git.cp()) local_author_offset = localtime(adate_sec).tm_gmtoff local_committer_offset = localtime(cdate_sec).tm_gmtoff WVPASSEQ(tree, commit_items.tree.decode('hex')) WVPASSEQ(1, len(commit_items.parents)) WVPASSEQ(parent, commit_items.parents[0].decode('hex')) WVPASSEQ(author_name, commit_items.author_name) WVPASSEQ(author_mail, commit_items.author_mail) WVPASSEQ(adate_sec, commit_items.author_sec) WVPASSEQ(local_author_offset, commit_items.author_offset) WVPASSEQ(committer_name, commit_items.committer_name) WVPASSEQ(committer_mail, commit_items.committer_mail) WVPASSEQ(cdate_sec, commit_items.committer_sec) WVPASSEQ(local_committer_offset, commit_items.committer_offset) commit_items = git.get_commit_items(commit_off.encode('hex'), git.cp()) WVPASSEQ(tree, commit_items.tree.decode('hex')) WVPASSEQ(1, len(commit_items.parents)) WVPASSEQ(parent, commit_items.parents[0].decode('hex')) WVPASSEQ(author_name, commit_items.author_name) WVPASSEQ(author_mail, commit_items.author_mail) WVPASSEQ(adate_sec, commit_items.author_sec) WVPASSEQ(adate_tz_sec, commit_items.author_offset) WVPASSEQ(committer_name, commit_items.committer_name) WVPASSEQ(committer_mail, commit_items.committer_mail) WVPASSEQ(cdate_sec, commit_items.committer_sec) WVPASSEQ(cdate_tz_sec, commit_items.committer_offset)
def test_new_commit(): initial_failures = wvfailure_count() tmpdir = tempfile.mkdtemp(dir=bup_tmp, prefix='bup-tgit-') os.environ['BUP_MAIN_EXE'] = bup_exe os.environ['BUP_DIR'] = bupdir = tmpdir + "/bup" git.init_repo(bupdir) git.verbose = 1 w = git.PackWriter() tree = os.urandom(20) parent = os.urandom(20) author_name = 'Author' author_mail = 'author@somewhere' adate_sec = 1439657836 cdate_sec = adate_sec + 1 committer_name = 'Committer' committer_mail = 'committer@somewhere' adate_tz_sec = cdate_tz_sec = None commit = w.new_commit(tree, parent, '%s <%s>' % (author_name, author_mail), adate_sec, adate_tz_sec, '%s <%s>' % (committer_name, committer_mail), cdate_sec, cdate_tz_sec, 'There is a small mailbox here') adate_tz_sec = -60 * 60 cdate_tz_sec = 120 * 60 commit_off = w.new_commit(tree, parent, '%s <%s>' % (author_name, author_mail), adate_sec, adate_tz_sec, '%s <%s>' % (committer_name, committer_mail), cdate_sec, cdate_tz_sec, 'There is a small mailbox here') w.close() commit_items = git.get_commit_items(commit.encode('hex'), git.cp()) local_author_offset = localtime(adate_sec).tm_gmtoff local_committer_offset = localtime(cdate_sec).tm_gmtoff WVPASSEQ(tree, commit_items.tree.decode('hex')) WVPASSEQ(1, len(commit_items.parents)) WVPASSEQ(parent, commit_items.parents[0].decode('hex')) WVPASSEQ(author_name, commit_items.author_name) WVPASSEQ(author_mail, commit_items.author_mail) WVPASSEQ(adate_sec, commit_items.author_sec) WVPASSEQ(local_author_offset, commit_items.author_offset) WVPASSEQ(committer_name, commit_items.committer_name) WVPASSEQ(committer_mail, commit_items.committer_mail) WVPASSEQ(cdate_sec, commit_items.committer_sec) WVPASSEQ(local_committer_offset, commit_items.committer_offset) commit_items = git.get_commit_items(commit_off.encode('hex'), git.cp()) WVPASSEQ(tree, commit_items.tree.decode('hex')) WVPASSEQ(1, len(commit_items.parents)) WVPASSEQ(parent, commit_items.parents[0].decode('hex')) WVPASSEQ(author_name, commit_items.author_name) WVPASSEQ(author_mail, commit_items.author_mail) WVPASSEQ(adate_sec, commit_items.author_sec) WVPASSEQ(adate_tz_sec, commit_items.author_offset) WVPASSEQ(committer_name, commit_items.committer_name) WVPASSEQ(committer_mail, commit_items.committer_mail) WVPASSEQ(cdate_sec, commit_items.committer_sec) WVPASSEQ(cdate_tz_sec, commit_items.committer_offset) if wvfailure_count() == initial_failures: subprocess.call(['rm', '-rf', tmpdir])