diff options
author | Don Garrett <dgarrett@google.com> | 2015-04-02 20:48:12 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-04-03 19:50:40 +0000 |
commit | ea9c8c163a38d94663d24e8bc03e3e26f6c28feb (patch) | |
tree | 305d3769540e4861ffaad625a807a3704e2053fd /cbuildbot/repository_unittest.py | |
parent | 871216229c9ca840139661feeb84a4bdeca25583 (diff) | |
download | chromite-ea9c8c163a38d94663d24e8bc03e3e26f6c28feb.tar.gz |
brillo sdk: Allow multiple explicit checkouts to the same directory.
We were blowing up if you did:
brillo sdk --update latest --sdk-dir foo
brillo sdk --update latest --sdk-dir foo
This was because we created a temporary git repository to put the
manifest into, then threw it away. If you try to switch git
repositories under repo (for the next command run), it gets mad.
Now we will create foo/.local_manifest_repo for the source manifests
git repo instead of throwing them away.
This CL also updates repository.PrepManifestForRepo() to support
reusing the same git repository more than once.
One problem with this fix, you still won't be able to update SDK
checkouts that were created before this CL was landed.
BUG=brillo:719
TEST=Lint + Unittests + the above command lines.
Change-Id: I890894c4e7f0723b773aa8344d903263667aa6e5
Reviewed-on: https://chromium-review.googlesource.com/263808
Trybot-Ready: Don Garrett <dgarrett@chromium.org>
Tested-by: Don Garrett <dgarrett@chromium.org>
Reviewed-by: David Pursell <dpursell@chromium.org>
Commit-Queue: Don Garrett <dgarrett@chromium.org>
Diffstat (limited to 'cbuildbot/repository_unittest.py')
-rw-r--r-- | cbuildbot/repository_unittest.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/cbuildbot/repository_unittest.py b/cbuildbot/repository_unittest.py index 00010ff8a..ccd5eb0ec 100644 --- a/cbuildbot/repository_unittest.py +++ b/cbuildbot/repository_unittest.py @@ -95,3 +95,29 @@ class PrepManifestForRepoTests(cros_test_lib.TempDirTestCase): # This should fail if we don't have a valid Git repo. Not a perfect test. git.GetGitRepoRevision(git_repo) + + def testUpdatingManifestRepo(self): + """Test we can update manifest in a local git repository.""" + CONTENTS = 'manifest contents' + CONTENTS2 = 'manifest contents - PART 2' + + src_manifest = os.path.join(self.tempdir, 'src_manifest') + git_repo = os.path.join(self.tempdir, 'git_repo') + dst_manifest = os.path.join(git_repo, 'default.xml') + + # Do/verify initial repo setup. + osutils.WriteFile(src_manifest, CONTENTS) + repository.PrepManifestForRepo(git_repo, src_manifest) + + self.assertEqual(CONTENTS, osutils.ReadFile(dst_manifest)) + + # Update it. + osutils.WriteFile(src_manifest, CONTENTS2) + repository.PrepManifestForRepo(git_repo, src_manifest) + + self.assertEqual(CONTENTS2, osutils.ReadFile(dst_manifest)) + + # Update it again with same manifest. + repository.PrepManifestForRepo(git_repo, src_manifest) + + self.assertEqual(CONTENTS2, osutils.ReadFile(dst_manifest)) |