fix(release): 支持提示中的带引号确认回复 #34
@@ -70,7 +70,7 @@ def resolve(task, event):
|
||||
return sha, sha
|
||||
|
||||
|
||||
def frozen_approval(task_id):
|
||||
def frozen_approval(task_id, comment_id=None):
|
||||
"""An owner reply to the specific, unedited scope preview authorizes this immutable local plan."""
|
||||
path = DIRECTORY / (task_id + '.preview.json')
|
||||
if not path.exists():
|
||||
@@ -81,8 +81,11 @@ def frozen_approval(task_id):
|
||||
cd.require(parent.get('content') == saved['content'], 'scope preview has changed')
|
||||
replies = [r for r in rows if r.get('parentId') == saved['comment'] and author(r) == cd.RELEASE_OWNER
|
||||
and (r.get('author') or {}).get('type') == 'human' and not r.get('runId')]
|
||||
if replies and max(replies, key=lambda r: r['createdAt'])['content'].strip() == '确认范围':
|
||||
return saved['plan']
|
||||
if replies:
|
||||
latest = max(replies, key=lambda r: r['createdAt'])
|
||||
if ((comment_id is None or latest['id'] == comment_id)
|
||||
and latest['content'].strip() in ('确认范围', '「确认范围」')):
|
||||
return saved['plan']
|
||||
return None
|
||||
|
||||
|
||||
@@ -172,7 +175,7 @@ def main():
|
||||
if args.action == 'preflight':
|
||||
return preflight(task, args.comment)
|
||||
if args.action == 'scope':
|
||||
cd.require(author(row) == cd.RELEASE_OWNER and row['content'].strip() == '确认范围' and frozen_approval(task['id']),
|
||||
cd.require(frozen_approval(task['id'], row['id']),
|
||||
'require the release owner reply on the exact scope preview')
|
||||
return coordinator.queue(task['id'])
|
||||
return qa(task, row)
|
||||
|
||||
@@ -31,6 +31,10 @@ class ReleaseHandoffTest(unittest.TestCase):
|
||||
'author': {'id': h.cd.RELEASE_OWNER, 'type': 'human'}}
|
||||
with patch.object(h, 'comments', return_value=[parent, reply]):
|
||||
self.assertEqual(h.frozen_approval('task'), saved['plan'])
|
||||
quoted = dict(reply, content='「确认范围」')
|
||||
with patch.object(h, 'comments', return_value=[parent, quoted]):
|
||||
self.assertEqual(h.frozen_approval('task', 'ok'), saved['plan'])
|
||||
self.assertIsNone(h.frozen_approval('task', 'other'))
|
||||
for bad in (dict(reply, parentId=None), dict(reply, runId='agent-run'), dict(reply, content='先不确认范围')):
|
||||
with patch.object(h, 'comments', return_value=[parent, bad]):
|
||||
self.assertIsNone(h.frozen_approval('task'))
|
||||
|
||||
Reference in New Issue
Block a user