mirror of
https://github.com/rpm-software-management/tito.git
synced 2025-02-23 20:22:46 +00:00
deprecate GitPython
GitPython is not compatible with python3 and may never be: https://fedoraproject.org/wiki/User:Churchyard/python3
This commit is contained in:
parent
a0d0f859c7
commit
3ae1596923
4 changed files with 28 additions and 33 deletions
|
@ -12,7 +12,6 @@
|
||||||
# granted to use or replicate Red Hat trademarks that are incorporated
|
# granted to use or replicate Red Hat trademarks that are incorporated
|
||||||
# in this software or its documentation.
|
# in this software or its documentation.
|
||||||
|
|
||||||
import git
|
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
|
@ -117,23 +116,15 @@ class TitoGitTestFixture(unittest.TestCase):
|
||||||
print("Testing in: %s" % self.repo_dir)
|
print("Testing in: %s" % self.repo_dir)
|
||||||
print
|
print
|
||||||
|
|
||||||
# GitPython calls os.login(), which throws OSError if there is no tty,
|
|
||||||
# but GitPython allows to avoid the call if env var USER exists.
|
|
||||||
try:
|
|
||||||
os.getlogin()
|
|
||||||
except OSError:
|
|
||||||
os.environ['USER'] = 'nobody'
|
|
||||||
|
|
||||||
# Initialize the repo:
|
# Initialize the repo:
|
||||||
self.repo = git.Repo.init(path=self.repo_dir, mkdir=True, bare=False)
|
os.chdir(self.repo_dir)
|
||||||
|
run_command('git init')
|
||||||
|
|
||||||
# Next we tito init:
|
# Next we tito init:
|
||||||
os.chdir(self.repo_dir)
|
|
||||||
tito("init")
|
tito("init")
|
||||||
run_command('echo "offline = true" >> rel-eng/tito.props')
|
run_command('echo "offline = true" >> rel-eng/tito.props')
|
||||||
index = self.repo.index
|
run_command('git add rel-eng/tito.props')
|
||||||
index.add(['rel-eng/tito.props'])
|
run_command("git commit -m 'set offline in tito.props'")
|
||||||
index.commit('Setting offline.')
|
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
shutil.rmtree(self.repo_dir)
|
shutil.rmtree(self.repo_dir)
|
||||||
|
@ -196,13 +187,12 @@ class TitoGitTestFixture(unittest.TestCase):
|
||||||
out_f.write(TEST_PYTHON_SRC)
|
out_f.write(TEST_PYTHON_SRC)
|
||||||
out_f.close()
|
out_f.close()
|
||||||
|
|
||||||
index = self.repo.index
|
|
||||||
files = [os.path.join(pkg_dir, 'a.txt'),
|
files = [os.path.join(pkg_dir, 'a.txt'),
|
||||||
os.path.join(pkg_dir, 'setup.py'),
|
os.path.join(pkg_dir, 'setup.py'),
|
||||||
os.path.join(pkg_dir, '%s.spec' % pkg_name),
|
os.path.join(pkg_dir, '%s.spec' % pkg_name),
|
||||||
os.path.join(pkg_dir, 'src/module.py')
|
os.path.join(pkg_dir, 'src/module.py')
|
||||||
]
|
]
|
||||||
index.add(files)
|
run_command('git add %s' % ' '.join(files))
|
||||||
index.commit('Initial commit.')
|
run_command("git commit -m 'initial commit'")
|
||||||
|
|
||||||
tito('tag --keep-version --debug --accept-auto-changelog')
|
tito('tag --keep-version --debug --accept-auto-changelog')
|
||||||
|
|
|
@ -68,20 +68,19 @@ class MultiProjectTests(TitoGitTestFixture):
|
||||||
self.create_project(TEST_PKG_1, os.path.join(self.repo_dir, 'pkg1'))
|
self.create_project(TEST_PKG_1, os.path.join(self.repo_dir, 'pkg1'))
|
||||||
self.create_project(TEST_PKG_2, os.path.join(self.repo_dir, 'pkg2'))
|
self.create_project(TEST_PKG_2, os.path.join(self.repo_dir, 'pkg2'))
|
||||||
self.create_project(TEST_PKG_3, os.path.join(self.repo_dir, 'pkg3'))
|
self.create_project(TEST_PKG_3, os.path.join(self.repo_dir, 'pkg3'))
|
||||||
os.chdir(self.repo_dir)
|
|
||||||
|
|
||||||
# For second test package, use a tito.props to override and use the
|
# For second test package, use a tito.props to override and use the
|
||||||
# ReleaseTagger:
|
# ReleaseTagger:
|
||||||
os.chdir(os.path.join(self.repo_dir, 'pkg2'))
|
|
||||||
filename = os.path.join(self.repo_dir, 'pkg2', "tito.props")
|
filename = os.path.join(self.repo_dir, 'pkg2', "tito.props")
|
||||||
out_f = open(filename, 'w')
|
out_f = open(filename, 'w')
|
||||||
out_f.write("[buildconfig]\n")
|
out_f.write("[buildconfig]\n")
|
||||||
out_f.write("tagger = tito.tagger.ReleaseTagger\n")
|
out_f.write("tagger = tito.tagger.ReleaseTagger\n")
|
||||||
out_f.write("builder = tito.builder.Builder\n")
|
out_f.write("builder = tito.builder.Builder\n")
|
||||||
out_f.close()
|
out_f.close()
|
||||||
index = self.repo.index
|
|
||||||
index.add(['pkg2/tito.props'])
|
os.chdir(self.repo_dir)
|
||||||
index.commit("Adding tito.props for pkg2.")
|
run_command('git add pkg2/tito.props')
|
||||||
|
run_command("git commit -m 'add tito.props for pkg2'")
|
||||||
|
|
||||||
def test_template_version_tagger(self):
|
def test_template_version_tagger(self):
|
||||||
"""
|
"""
|
||||||
|
@ -94,9 +93,10 @@ class MultiProjectTests(TitoGitTestFixture):
|
||||||
run_command('mkdir -p %s' % join(self.repo_dir, 'rel-eng/templates'))
|
run_command('mkdir -p %s' % join(self.repo_dir, 'rel-eng/templates'))
|
||||||
self.write_file(join(self.repo_dir,
|
self.write_file(join(self.repo_dir,
|
||||||
'rel-eng/templates/version.rb'), VERSION_TEMPLATE_FILE)
|
'rel-eng/templates/version.rb'), VERSION_TEMPLATE_FILE)
|
||||||
index = self.repo.index
|
|
||||||
index.add(['pkg3/tito.props'])
|
os.chdir(self.repo_dir)
|
||||||
index.commit("Adding tito.props for pkg3.")
|
run_command('git add pkg3/tito.props')
|
||||||
|
run_command("git commit -m 'add tito.props for pkg3'")
|
||||||
|
|
||||||
# Create another pkg3 tag and make sure we got a generated
|
# Create another pkg3 tag and make sure we got a generated
|
||||||
# template file.
|
# template file.
|
||||||
|
|
|
@ -49,14 +49,21 @@ class SingleProjectTests(TitoGitTestFixture):
|
||||||
check_tag_exists("%s-9.0.0-1" % PKG_NAME, offline=True)
|
check_tag_exists("%s-9.0.0-1" % PKG_NAME, offline=True)
|
||||||
|
|
||||||
def test_undo_tag(self):
|
def test_undo_tag(self):
|
||||||
commit = self.repo.heads.master.commit
|
os.chdir(self.repo_dir)
|
||||||
|
original_head = getoutput('git show-ref -s refs/heads/master')
|
||||||
|
|
||||||
|
# Create tito tag, which adds a new commit and moves head.
|
||||||
tito("tag --accept-auto-changelog --debug")
|
tito("tag --accept-auto-changelog --debug")
|
||||||
tag = "%s-0.0.2-1" % PKG_NAME
|
tag = "%s-0.0.2-1" % PKG_NAME
|
||||||
check_tag_exists(tag, offline=True)
|
check_tag_exists(tag, offline=True)
|
||||||
self.assertNotEqual(commit, self.repo.heads.master.commit)
|
new_head = getoutput('git show-ref -s refs/heads/master')
|
||||||
|
self.assertNotEqual(original_head, new_head)
|
||||||
|
|
||||||
|
# Undo tito tag, which rewinds one commit to original head.
|
||||||
tito("tag -u")
|
tito("tag -u")
|
||||||
self.assertFalse(tag_exists_locally(tag))
|
self.assertFalse(tag_exists_locally(tag))
|
||||||
self.assertEqual(commit, self.repo.heads.master.commit)
|
new_head = getoutput('git show-ref -s refs/heads/master')
|
||||||
|
self.assertEqual(original_head, new_head)
|
||||||
|
|
||||||
def test_latest_tgz(self):
|
def test_latest_tgz(self):
|
||||||
tito("build --tgz -o %s" % self.repo_dir)
|
tito("build --tgz -o %s" % self.repo_dir)
|
||||||
|
|
|
@ -25,9 +25,7 @@ class TitoUnitTestFixture(unittest.TestCase):
|
||||||
Fixture providing setup/teardown and utilities for unit tests.
|
Fixture providing setup/teardown and utilities for unit tests.
|
||||||
"""
|
"""
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
# GitPython calls os.login(), which throws OSError if there is no tty,
|
print
|
||||||
# but GitPython allows to avoid the call if env var USER exists.
|
print
|
||||||
try:
|
print("Testing in: %s" % REPO_DIR)
|
||||||
os.getlogin()
|
print
|
||||||
except OSError:
|
|
||||||
os.environ['USER'] = 'nobody'
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue