- with no_lingering_errors(), test_tempdir('bup-tgit-') as tmpdir:
- orig_cwd = os.getcwd()
- workdir = tmpdir + "/work"
- repodir = workdir + '/.git'
- orig_author_name = os.environ.get('GIT_AUTHOR_NAME')
- orig_author_email = os.environ.get('GIT_AUTHOR_EMAIL')
- orig_committer_name = os.environ.get('GIT_COMMITTER_NAME')
- orig_committer_email = os.environ.get('GIT_COMMITTER_EMAIL')
- os.environ['GIT_AUTHOR_NAME'] = 'bup test'
- os.environ['GIT_COMMITTER_NAME'] = os.environ['GIT_AUTHOR_NAME']
- os.environ['GIT_AUTHOR_EMAIL'] = 'bup@a425bc70a02811e49bdf73ee56450e6f'
- os.environ['GIT_COMMITTER_EMAIL'] = os.environ['GIT_AUTHOR_EMAIL']
- try:
- readpipe(['git', 'init', workdir])
- os.environ['GIT_DIR'] = os.environ['BUP_DIR'] = repodir
- git.check_repo_or_die(repodir)
- os.chdir(workdir)
- with open('foo', 'w') as f:
- print >> f, 'bar'
- readpipe(['git', 'add', '.'])
- readpipe(['git', 'commit', '-am', 'Do something',
- '--author', 'Someone <someone@somewhere>',
- '--date', 'Sat Oct 3 19:48:49 2009 -0400'])
- commit = readpipe(['git', 'show-ref', '-s', 'master']).strip()
- parents = showval(commit, '%P')
- tree = showval(commit, '%T')
- cname = showval(commit, '%cn')
- cmail = showval(commit, '%ce')
- cdate = showval(commit, '%ct')
- coffs = showval(commit, '%ci')
- coffs = coffs[-5:]
- coff = (int(coffs[-4:-2]) * 60 * 60) + (int(coffs[-2:]) * 60)
- if coffs[-5] == '-':
- coff = - coff
- commit_items = git.get_commit_items(commit, git.cp())
- WVPASSEQ(commit_items.parents, [])
- WVPASSEQ(commit_items.tree, tree)
- WVPASSEQ(commit_items.author_name, 'Someone')
- WVPASSEQ(commit_items.author_mail, 'someone@somewhere')
- WVPASSEQ(commit_items.author_sec, 1254613729)
- WVPASSEQ(commit_items.author_offset, -(4 * 60 * 60))
- WVPASSEQ(commit_items.committer_name, cname)
- WVPASSEQ(commit_items.committer_mail, cmail)
- WVPASSEQ(commit_items.committer_sec, int(cdate))
- WVPASSEQ(commit_items.committer_offset, coff)
- WVPASSEQ(commit_items.message, 'Do something\n')
- with open('bar', 'w') as f:
- print >> f, 'baz'
- readpipe(['git', 'add', '.'])
- readpipe(['git', 'commit', '-am', 'Do something else'])
- child = readpipe(['git', 'show-ref', '-s', 'master']).strip()
- parents = showval(child, '%P')
- commit_items = git.get_commit_items(child, git.cp())
- WVPASSEQ(commit_items.parents, [commit])
- finally:
- os.chdir(orig_cwd)
- restore_env_var('GIT_AUTHOR_NAME', orig_author_name)
- restore_env_var('GIT_AUTHOR_EMAIL', orig_author_email)
- restore_env_var('GIT_COMMITTER_NAME', orig_committer_name)
- restore_env_var('GIT_COMMITTER_EMAIL', orig_committer_email)
+ with no_lingering_errors():
+ with test_tempdir('bup-tgit-') as tmpdir:
+ orig_cwd = os.getcwd()
+ workdir = tmpdir + "/work"
+ repodir = workdir + '/.git'
+ orig_author_name = os.environ.get('GIT_AUTHOR_NAME')
+ orig_author_email = os.environ.get('GIT_AUTHOR_EMAIL')
+ orig_committer_name = os.environ.get('GIT_COMMITTER_NAME')
+ orig_committer_email = os.environ.get('GIT_COMMITTER_EMAIL')
+ os.environ['GIT_AUTHOR_NAME'] = 'bup test'
+ os.environ['GIT_COMMITTER_NAME'] = os.environ['GIT_AUTHOR_NAME']
+ os.environ['GIT_AUTHOR_EMAIL'] = 'bup@a425bc70a02811e49bdf73ee56450e6f'
+ os.environ['GIT_COMMITTER_EMAIL'] = os.environ['GIT_AUTHOR_EMAIL']
+ try:
+ readpipe(['git', 'init', workdir])
+ os.environ['GIT_DIR'] = os.environ['BUP_DIR'] = repodir
+ git.check_repo_or_die(repodir)
+ os.chdir(workdir)
+ with open('foo', 'w') as f:
+ print('bar', file=f)
+ readpipe(['git', 'add', '.'])
+ readpipe(['git', 'commit', '-am', 'Do something',
+ '--author', 'Someone <someone@somewhere>',
+ '--date', 'Sat Oct 3 19:48:49 2009 -0400'])
+ commit = readpipe(['git', 'show-ref', '-s', 'master']).strip()
+ parents = showval(commit, '%P')
+ tree = showval(commit, '%T')
+ cname = showval(commit, '%cn')
+ cmail = showval(commit, '%ce')
+ cdate = showval(commit, '%ct')
+ coffs = showval(commit, '%ci')
+ coffs = coffs[-5:]
+ coff = (int(coffs[-4:-2]) * 60 * 60) + (int(coffs[-2:]) * 60)
+ if coffs[-5] == '-':
+ coff = - coff
+ commit_items = git.get_commit_items(commit, git.cp())
+ WVPASSEQ(commit_items.parents, [])
+ WVPASSEQ(commit_items.tree, tree)
+ WVPASSEQ(commit_items.author_name, 'Someone')
+ WVPASSEQ(commit_items.author_mail, 'someone@somewhere')
+ WVPASSEQ(commit_items.author_sec, 1254613729)
+ WVPASSEQ(commit_items.author_offset, -(4 * 60 * 60))
+ WVPASSEQ(commit_items.committer_name, cname)
+ WVPASSEQ(commit_items.committer_mail, cmail)
+ WVPASSEQ(commit_items.committer_sec, int(cdate))
+ WVPASSEQ(commit_items.committer_offset, coff)
+ WVPASSEQ(commit_items.message, 'Do something\n')
+ with open('bar', 'w') as f:
+ print('baz', file=f)
+ readpipe(['git', 'add', '.'])
+ readpipe(['git', 'commit', '-am', 'Do something else'])
+ child = readpipe(['git', 'show-ref', '-s', 'master']).strip()
+ parents = showval(child, '%P')
+ commit_items = git.get_commit_items(child, git.cp())
+ WVPASSEQ(commit_items.parents, [commit])
+ finally:
+ os.chdir(orig_cwd)
+ restore_env_var('GIT_AUTHOR_NAME', orig_author_name)
+ restore_env_var('GIT_AUTHOR_EMAIL', orig_author_email)
+ restore_env_var('GIT_COMMITTER_NAME', orig_committer_name)
+ restore_env_var('GIT_COMMITTER_EMAIL', orig_committer_email)