Make release scripts more robust.
Remembering the current branch is a relic from the past where no work-dir checkout was used. Now this doesn't give much benefit and screws up the script if it was left in a bad state (e.g. after a master restart). TBR=tandrii@chromium.org NOTRY=true Review URL: https://codereview.chromium.org/1002383002 Cr-Commit-Position: refs/heads/master@{#27196}
This commit is contained in:
parent
4d23fc1ecf
commit
db7e074d92
@ -538,8 +538,8 @@ class Step(GitRecipesMixin):
|
||||
if not self.GitIsWorkdirClean(): # pragma: no cover
|
||||
self.Die("Workspace is not clean. Please commit or undo your changes.")
|
||||
|
||||
# Persist current branch.
|
||||
self["current_branch"] = self.GitCurrentBranch()
|
||||
# Checkout master in case the script was left on a work branch.
|
||||
self.GitCheckout('origin/master')
|
||||
|
||||
# Fetch unfetched revisions.
|
||||
self.vc.Fetch()
|
||||
@ -549,12 +549,8 @@ class Step(GitRecipesMixin):
|
||||
self.DeleteBranch(self._config["BRANCHNAME"])
|
||||
|
||||
def CommonCleanup(self):
|
||||
if ' ' in self["current_branch"]:
|
||||
self.GitCheckout('master')
|
||||
else:
|
||||
self.GitCheckout(self["current_branch"])
|
||||
if self._config["BRANCHNAME"] != self["current_branch"]:
|
||||
self.GitDeleteBranch(self._config["BRANCHNAME"])
|
||||
self.GitCheckout('origin/master')
|
||||
self.GitDeleteBranch(self._config["BRANCHNAME"])
|
||||
|
||||
# Clean up all temporary files.
|
||||
for f in glob.iglob("%s*" % self._config["PERSISTFILE_BASENAME"]):
|
||||
|
@ -437,7 +437,7 @@ class ScriptTest(unittest.TestCase):
|
||||
def testCommonPrepareDefault(self):
|
||||
self.Expect([
|
||||
Cmd("git status -s -uno", ""),
|
||||
Cmd("git status -s -b -uno", "## some_branch"),
|
||||
Cmd("git checkout -f origin/master", ""),
|
||||
Cmd("git fetch", ""),
|
||||
Cmd("git branch", " branch1\n* %s" % TEST_CONFIG["BRANCHNAME"]),
|
||||
RL("Y"),
|
||||
@ -445,24 +445,22 @@ class ScriptTest(unittest.TestCase):
|
||||
])
|
||||
self.MakeStep().CommonPrepare()
|
||||
self.MakeStep().PrepareBranch()
|
||||
self.assertEquals("some_branch", self._state["current_branch"])
|
||||
|
||||
def testCommonPrepareNoConfirm(self):
|
||||
self.Expect([
|
||||
Cmd("git status -s -uno", ""),
|
||||
Cmd("git status -s -b -uno", "## some_branch"),
|
||||
Cmd("git checkout -f origin/master", ""),
|
||||
Cmd("git fetch", ""),
|
||||
Cmd("git branch", " branch1\n* %s" % TEST_CONFIG["BRANCHNAME"]),
|
||||
RL("n"),
|
||||
])
|
||||
self.MakeStep().CommonPrepare()
|
||||
self.assertRaises(Exception, self.MakeStep().PrepareBranch)
|
||||
self.assertEquals("some_branch", self._state["current_branch"])
|
||||
|
||||
def testCommonPrepareDeleteBranchFailure(self):
|
||||
self.Expect([
|
||||
Cmd("git status -s -uno", ""),
|
||||
Cmd("git status -s -b -uno", "## some_branch"),
|
||||
Cmd("git checkout -f origin/master", ""),
|
||||
Cmd("git fetch", ""),
|
||||
Cmd("git branch", " branch1\n* %s" % TEST_CONFIG["BRANCHNAME"]),
|
||||
RL("Y"),
|
||||
@ -470,7 +468,6 @@ class ScriptTest(unittest.TestCase):
|
||||
])
|
||||
self.MakeStep().CommonPrepare()
|
||||
self.assertRaises(Exception, self.MakeStep().PrepareBranch)
|
||||
self.assertEquals("some_branch", self._state["current_branch"])
|
||||
|
||||
def testInitialEnvironmentChecks(self):
|
||||
TextToFile("", os.path.join(TEST_CONFIG["DEFAULT_CWD"], ".git"))
|
||||
@ -774,7 +771,7 @@ Performance and stability improvements on all platforms."""
|
||||
expectations.append(Cmd("which vi", "/usr/bin/vi"))
|
||||
expectations += [
|
||||
Cmd("git status -s -uno", ""),
|
||||
Cmd("git status -s -b -uno", "## some_branch\n"),
|
||||
Cmd("git checkout -f origin/master", ""),
|
||||
Cmd("git fetch", ""),
|
||||
Cmd("git branch", " branch1\n* branch2\n"),
|
||||
Cmd("git branch", " branch1\n* branch2\n"),
|
||||
@ -828,7 +825,7 @@ Performance and stability improvements on all platforms."""
|
||||
" origin/candidates", "hsh_to_tag"),
|
||||
Cmd("git tag 3.22.5 hsh_to_tag", ""),
|
||||
Cmd("git push origin 3.22.5", ""),
|
||||
Cmd("git checkout -f some_branch", ""),
|
||||
Cmd("git checkout -f origin/master", ""),
|
||||
Cmd("git branch -D %s" % TEST_CONFIG["BRANCHNAME"], ""),
|
||||
Cmd("git branch -D %s" % TEST_CONFIG["CANDIDATESBRANCH"], ""),
|
||||
]
|
||||
@ -1189,7 +1186,7 @@ LOG=N
|
||||
|
||||
self.Expect([
|
||||
Cmd("git status -s -uno", ""),
|
||||
Cmd("git status -s -b -uno", "## some_branch\n"),
|
||||
Cmd("git checkout -f origin/master", ""),
|
||||
Cmd("git fetch", ""),
|
||||
Cmd("git branch", " branch1\n* branch2\n"),
|
||||
Cmd("git new-branch %s --upstream refs/remotes/origin/candidates" %
|
||||
@ -1263,7 +1260,7 @@ LOG=N
|
||||
"hsh_to_tag"),
|
||||
Cmd("git tag 3.22.5.1 hsh_to_tag", ""),
|
||||
Cmd("git push origin 3.22.5.1", ""),
|
||||
Cmd("git checkout -f some_branch", ""),
|
||||
Cmd("git checkout -f origin/master", ""),
|
||||
Cmd("git branch -D %s" % TEST_CONFIG["BRANCHNAME"], ""),
|
||||
])
|
||||
|
||||
@ -1350,7 +1347,7 @@ Cr-Commit-Position: refs/heads/4.2.71@{#1}
|
||||
|
||||
self.Expect([
|
||||
Cmd("git status -s -uno", ""),
|
||||
Cmd("git status -s -b -uno", "## some_branch\n"),
|
||||
Cmd("git checkout -f origin/master", ""),
|
||||
Cmd("git fetch", ""),
|
||||
Cmd("git branch", " branch1\n* branch2\n"),
|
||||
Cmd("git new-branch %s" % TEST_CONFIG["BRANCHNAME"], ""),
|
||||
@ -1443,7 +1440,7 @@ Cr-Commit-Position: refs/heads/4.2.71@{#1}
|
||||
cwd=chrome_dir),
|
||||
Cmd("git checkout -f master", "", cwd=chrome_dir),
|
||||
Cmd("git branch -D %s" % TEST_CONFIG["BRANCHNAME"], "", cwd=chrome_dir),
|
||||
Cmd("git checkout -f some_branch", ""),
|
||||
Cmd("git checkout -f origin/master", ""),
|
||||
Cmd("git branch -D %s" % TEST_CONFIG["BRANCHNAME"], ""),
|
||||
])
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user