release tooling changes
This commit is contained in:
parent
6680f39e73
commit
cce5208917
|
@ -0,0 +1,34 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
Twisted moved the C{twisted} hierarchy to the C{src} hierarchy, but C{git}
|
||||
doesn't know how to track moves of directories, only files. Therefore any
|
||||
files added in branches after this move will be added into ./twisted/ and need
|
||||
to be moved over into
|
||||
"""
|
||||
|
||||
import os
|
||||
from twisted.python.filepath import FilePath
|
||||
|
||||
here = FilePath(__file__).parent().parent()
|
||||
twistedPath = here.child("src").child("twisted")
|
||||
|
||||
def mv(fromPath):
|
||||
|
||||
for fn in fromPath.walk():
|
||||
if fn.isfile():
|
||||
os.system("git mv {fr} {to}"
|
||||
.format(
|
||||
fr=fn.path,
|
||||
to=fn.parent().parent().child(
|
||||
'newsfragments').child(fn.basename()).path
|
||||
|
||||
))
|
||||
|
||||
if twistedPath.child('topfiles').exists():
|
||||
mv(twistedPath.child('topfiles'))
|
||||
|
||||
for child in twistedPath.listdir():
|
||||
path = twistedPath.child(child).child('topfiles')
|
||||
if path.exists():
|
||||
mv(path)
|
|
@ -491,7 +491,7 @@ class BuildAPIDocsScript(object):
|
|||
|
||||
class CheckTopfileScript(object):
|
||||
"""
|
||||
A thing for checking whether a checkout has a topfile.
|
||||
A thing for checking whether a checkout has a newsfragment.
|
||||
"""
|
||||
def __init__(self, _print):
|
||||
self._print = _print
|
||||
|
@ -530,27 +530,27 @@ class CheckTopfileScript(object):
|
|||
|
||||
if len(files) == 1:
|
||||
if files[0] == os.sep.join(["docs", "fun", "Twisted.Quotes"]):
|
||||
self._print("Quotes change only; no topfile needed.")
|
||||
self._print("Quotes change only; no newsfragment needed.")
|
||||
sys.exit(0)
|
||||
|
||||
topfiles = []
|
||||
|
||||
for change in files:
|
||||
if os.sep + "topfiles" + os.sep in change:
|
||||
if os.sep + "newsfragments" + os.sep in change:
|
||||
if "." in change and change.rsplit(".", 1)[1] in TOPFILE_TYPES:
|
||||
topfiles.append(change)
|
||||
|
||||
if branch.startswith("release-"):
|
||||
if topfiles:
|
||||
self._print("No topfiles should be on the release branch.")
|
||||
self._print("No newsfragments should be on the release branch.")
|
||||
sys.exit(1)
|
||||
else:
|
||||
self._print("Release branch with no topfiles, all good.")
|
||||
self._print("Release branch with no newsfragments, all good.")
|
||||
sys.exit(0)
|
||||
|
||||
for change in topfiles:
|
||||
self._print("Found " + change)
|
||||
sys.exit(0)
|
||||
|
||||
self._print("No topfile found. Have you committed it?")
|
||||
self._print("No newsfragment found. Have you committed it?")
|
||||
sys.exit(1)
|
||||
|
|
|
@ -1039,7 +1039,8 @@ class CheckTopfileScriptTests(ExternalTempdirTestCase):
|
|||
CheckTopfileScript(logs.append).main([self.repo.path])
|
||||
|
||||
self.assertEqual(e.exception.args, (1,))
|
||||
self.assertEqual(logs[-1], "No topfile found. Have you committed it?")
|
||||
self.assertEqual(logs[-1],
|
||||
"No newsfragment found. Have you committed it?")
|
||||
|
||||
|
||||
def test_noChangeFromTrunk(self):
|
||||
|
@ -1098,7 +1099,7 @@ class CheckTopfileScriptTests(ExternalTempdirTestCase):
|
|||
|
||||
self.assertEqual(e.exception.args, (0,))
|
||||
self.assertEqual(logs[-1],
|
||||
"Release branch with no topfiles, all good.")
|
||||
"Release branch with no newsfragments, all good.")
|
||||
|
||||
|
||||
def test_releaseWithTopfiles(self):
|
||||
|
@ -1108,7 +1109,7 @@ class CheckTopfileScriptTests(ExternalTempdirTestCase):
|
|||
runCommand(["git", "checkout", "-b", "release-16.11111-9001"],
|
||||
cwd=self.repo.path)
|
||||
|
||||
topfiles = self.repo.child("twisted").child("topfiles")
|
||||
topfiles = self.repo.child("twisted").child("newsfragments")
|
||||
topfiles.makedirs()
|
||||
fragment = topfiles.child("1234.misc")
|
||||
fragment.setContent(b"")
|
||||
|
@ -1128,7 +1129,7 @@ class CheckTopfileScriptTests(ExternalTempdirTestCase):
|
|||
|
||||
self.assertEqual(e.exception.args, (1,))
|
||||
self.assertEqual(logs[-1],
|
||||
"No topfiles should be on the release branch.")
|
||||
"No newsfragments should be on the release branch.")
|
||||
|
||||
|
||||
def test_onlyQuotes(self):
|
||||
|
@ -1155,7 +1156,7 @@ class CheckTopfileScriptTests(ExternalTempdirTestCase):
|
|||
|
||||
self.assertEqual(e.exception.args, (0,))
|
||||
self.assertEqual(logs[-1],
|
||||
"Quotes change only; no topfile needed.")
|
||||
"Quotes change only; no newsfragment needed.")
|
||||
|
||||
|
||||
def test_topfileAdded(self):
|
||||
|
@ -1166,7 +1167,7 @@ class CheckTopfileScriptTests(ExternalTempdirTestCase):
|
|||
runCommand(["git", "checkout", "-b", "quotefile"],
|
||||
cwd=self.repo.path)
|
||||
|
||||
topfiles = self.repo.child("twisted").child("topfiles")
|
||||
topfiles = self.repo.child("twisted").child("newsfragments")
|
||||
topfiles.makedirs()
|
||||
fragment = topfiles.child("1234.misc")
|
||||
fragment.setContent(b"")
|
||||
|
@ -1185,7 +1186,7 @@ class CheckTopfileScriptTests(ExternalTempdirTestCase):
|
|||
CheckTopfileScript(logs.append).main([self.repo.path])
|
||||
|
||||
self.assertEqual(e.exception.args, (0,))
|
||||
self.assertEqual(logs[-1], "Found twisted/topfiles/1234.misc")
|
||||
self.assertEqual(logs[-1], "Found twisted/newsfragments/1234.misc")
|
||||
|
||||
|
||||
def test_topfileButNotFragmentAdded(self):
|
||||
|
@ -1196,7 +1197,7 @@ class CheckTopfileScriptTests(ExternalTempdirTestCase):
|
|||
runCommand(["git", "checkout", "-b", "quotefile"],
|
||||
cwd=self.repo.path)
|
||||
|
||||
topfiles = self.repo.child("twisted").child("topfiles")
|
||||
topfiles = self.repo.child("twisted").child("newsfragments")
|
||||
topfiles.makedirs()
|
||||
notFragment = topfiles.child("1234.txt")
|
||||
notFragment.setContent(b"")
|
||||
|
@ -1215,7 +1216,8 @@ class CheckTopfileScriptTests(ExternalTempdirTestCase):
|
|||
CheckTopfileScript(logs.append).main([self.repo.path])
|
||||
|
||||
self.assertEqual(e.exception.args, (1,))
|
||||
self.assertEqual(logs[-1], "No topfile found. Have you committed it?")
|
||||
self.assertEqual(logs[-1],
|
||||
"No newsfragment found. Have you committed it?")
|
||||
|
||||
|
||||
def test_topfileAddedButWithOtherTopfiles(self):
|
||||
|
@ -1226,7 +1228,7 @@ class CheckTopfileScriptTests(ExternalTempdirTestCase):
|
|||
runCommand(["git", "checkout", "-b", "quotefile"],
|
||||
cwd=self.repo.path)
|
||||
|
||||
topfiles = self.repo.child("twisted").child("topfiles")
|
||||
topfiles = self.repo.child("twisted").child("newsfragments")
|
||||
topfiles.makedirs()
|
||||
fragment = topfiles.child("1234.misc")
|
||||
fragment.setContent(b"")
|
||||
|
@ -1245,4 +1247,4 @@ class CheckTopfileScriptTests(ExternalTempdirTestCase):
|
|||
CheckTopfileScript(logs.append).main([self.repo.path])
|
||||
|
||||
self.assertEqual(e.exception.args, (0,))
|
||||
self.assertEqual(logs[-1], "Found twisted/topfiles/1234.misc")
|
||||
self.assertEqual(logs[-1], "Found twisted/newsfragments/1234.misc")
|
||||
|
|
Loading…
Reference in New Issue