bodhi/controllers.py | 26 +++++++++++++++++++++++++-
bodhi/tests/test_controllers.py | 2 ++
2 files changed, 27 insertions(+), 1 deletion(-)
New commits:
commit 54ae5e1fe4bea5847f2a11758c0796f6ed4ce411
Author: Luke Macken <lmacken(a)redhat.com>
Date: Fri Sep 10 17:07:38 2010 -0400
Update our test_edit unit test to look for the new edit comments
diff --git a/bodhi/tests/test_controllers.py b/bodhi/tests/test_controllers.py
index 98a4bac..82ab882 100644
--- a/bodhi/tests/test_controllers.py
+++ b/bodhi/tests/test_controllers.py
@@ -499,6 +499,8 @@ class TestControllers(testutil.DBTest):
for build in PackageBuild.select():
assert len(build.updates), "%s has no updates!" % build.nvr
+ assert update.comments[-1].text == u'guest has edited this update. New
build(s): python-sqlobject-0.8.2-1.fc7. '
+
# Remove a build and bug
params = {
'builds' : 'python-sqlobject-0.8.2-1.fc7',
commit 4100581bf03feb85858acd0550e7d658532e26c6
Author: Luke Macken <lmacken(a)redhat.com>
Date: Fri Sep 10 17:05:35 2010 -0400
Improve our editing workflow, only unpushing when necessary (#474).
Determine if any builds have been added/removed from the update upon
editing, and only unpush it if this is the case. This way, people can
easily edit their update adding new bugs/notes without having to deal it it
getting unpushed/pushed again.
This will also add a comment to the update mentioning which builds have
been added/removed from the update.
diff --git a/bodhi/controllers.py b/bodhi/controllers.py
index 699a7ca..92282df 100644
--- a/bodhi/controllers.py
+++ b/bodhi/controllers.py
@@ -691,7 +691,31 @@ class Root(controllers.RootController):
edited.get_implied_build_tag(),
buildinfo[builds[0]]['tags']))
- edited.unpush()
+ # Determine which builds have been added or removed
+ edited_builds = [build.nvr for build in edited.builds]
+ new_builds = []
+ removed_builds = []
+ for build in builds:
+ if build not in edited_builds:
+ new_builds.append(build)
+ for build in edited_builds:
+ if build not in builds:
+ removed_builds.append(build)
+ if new_builds or removed_builds:
+ # Comment on the update with details of added/removed builds
+ comment = '%s has edited this update. ' %
identity.current.user_name
+ if new_builds:
+ comment += 'New build(s): %s. ' % ',
'.join(new_builds)
+ if removed_builds:
+ comment += 'Removed build(s): %s.' % ',
'.join(removed_builds)
+ edited.comment(comment, karma=0, author='bodhi')
+
+ # Make sure all builds are tagged as updates-candidate
+ # and bring the update back to a pending state
+ edited.unpush()
+ else:
+ # No need to change the bodhi state or koji tag
+ pass
# Refresh the tags for these builds
for build in edited.builds:
Show replies by date