Use merge date as a primary date for commit
Merge date is calculated as a date when the corresponding review was merged. Commit date is shown as separate field. Resolves bug 1204928 The idea of the fix is proposed by Chandan Kumar (chandankumar-093047) Change-Id: I7e3f38b3d4cdecf6e888382964df2187ece6a343
This commit is contained in:
parent
9ef5a95049
commit
a185ae84d2
@ -52,6 +52,8 @@ def extend_record(record):
|
||||
if 'correction_comment' not in record:
|
||||
record['correction_comment'] = ''
|
||||
record['message'] = make_commit_message(record)
|
||||
if record['commit_date']:
|
||||
record['commit_date_str'] = format_datetime(record['commit_date'])
|
||||
elif record['record_type'] == 'mark':
|
||||
parent = vault.get_memory_storage().get_record_by_primary_key(
|
||||
record['review_id'])
|
||||
|
@ -71,6 +71,9 @@
|
||||
{%if record_type == "commit" %}
|
||||
<div style='font-weight: bold;'>Commit “${subject}”</div>
|
||||
<div style='white-space: pre-wrap; '>{%html message %}</div>
|
||||
{%if commit_date_str != "" %}
|
||||
<div>Commit date: ${commit_date_str}</div>
|
||||
{%/if%}
|
||||
{%if correction_comment != "" %}
|
||||
<div style='font-weight: bold; color: red;'>Commit corrected:
|
||||
<span>${correction_comment}</span></div>
|
||||
|
@ -117,6 +117,9 @@
|
||||
{%/if%}
|
||||
<div style='font-weight: bold;'>${subject}</div>
|
||||
<div style='white-space: pre-wrap; '>{%html message %}</div>
|
||||
{%if commit_date_str != "" %}
|
||||
<div>Commit date: ${commit_date_str}</div>
|
||||
{%/if%}
|
||||
<div><span style="color: green">+<span>${lines_added}</span></span>
|
||||
<span style="color: blue">- <span>${lines_deleted}</span></span></div>
|
||||
{%elif record_type == "mark" %}
|
||||
|
@ -226,6 +226,7 @@ class RecordProcessor(object):
|
||||
record['primary_key'] = record['commit_id']
|
||||
record['loc'] = record['lines_added'] + record['lines_deleted']
|
||||
record['author_email'] = record['author_email'].lower()
|
||||
record['commit_date'] = record['date']
|
||||
|
||||
self._update_record_and_user(record)
|
||||
|
||||
@ -448,7 +449,26 @@ class RecordProcessor(object):
|
||||
if need_update:
|
||||
yield record
|
||||
|
||||
def _update_records_with_blueprint_mention_info(self):
|
||||
def _update_commits_with_merge_date(self):
|
||||
change_id_to_date = {}
|
||||
for record in self.runtime_storage_inst.get_all_records():
|
||||
if (record['record_type'] == 'review' and
|
||||
record.get('status') == 'MERGED'):
|
||||
change_id_to_date[record['id']] = record['lastUpdated']
|
||||
|
||||
for record in self.runtime_storage_inst.get_all_records():
|
||||
if record['record_type'] == 'commit':
|
||||
change_id_list = record.get('change_id')
|
||||
if change_id_list and len(change_id_list) == 1:
|
||||
change_id = change_id_list[0]
|
||||
if change_id in change_id_to_date:
|
||||
old_date = record['date']
|
||||
if old_date != change_id_to_date[change_id]:
|
||||
record['date'] = change_id_to_date[change_id]
|
||||
self._renew_record_date(record)
|
||||
yield record
|
||||
|
||||
def _update_blueprints_with_mention_info(self):
|
||||
LOG.debug('Process blueprints and calculate mention info')
|
||||
|
||||
valid_blueprints = {}
|
||||
@ -505,7 +525,7 @@ class RecordProcessor(object):
|
||||
if need_update:
|
||||
yield record
|
||||
|
||||
def _update_records_with_review_number(self):
|
||||
def _update_reviews_with_sequence_number(self):
|
||||
LOG.debug('Set review number in review records')
|
||||
|
||||
users_reviews = {}
|
||||
@ -556,7 +576,7 @@ class RecordProcessor(object):
|
||||
if user['core'] != core_old:
|
||||
utils.store_user(self.runtime_storage_inst, user)
|
||||
|
||||
def _update_records_with_disagreement(self):
|
||||
def _update_marks_with_disagreement(self):
|
||||
LOG.debug('Process marks to find disagreements')
|
||||
|
||||
marks_per_patch = {}
|
||||
@ -602,13 +622,16 @@ class RecordProcessor(object):
|
||||
self._update_records_with_user_info())
|
||||
|
||||
self.runtime_storage_inst.set_records(
|
||||
self._update_records_with_review_number())
|
||||
self._update_reviews_with_sequence_number())
|
||||
|
||||
self.runtime_storage_inst.set_records(
|
||||
self._update_records_with_blueprint_mention_info())
|
||||
self._update_blueprints_with_mention_info())
|
||||
|
||||
self.runtime_storage_inst.set_records(
|
||||
self._update_commits_with_merge_date())
|
||||
|
||||
self._determine_core_contributors()
|
||||
|
||||
# disagreement calculation must go after determining core contributors
|
||||
self.runtime_storage_inst.set_records(
|
||||
self._update_records_with_disagreement())
|
||||
self._update_marks_with_disagreement())
|
||||
|
@ -818,6 +818,36 @@ class TestRecordProcessor(testtools.TestCase):
|
||||
lambda x: x['date'] == 1385478465, marks), None)
|
||||
self.assertTrue(homer_mark['x']) # disagreement
|
||||
|
||||
def test_commit_merge_date(self):
|
||||
record_processor_inst = self.make_record_processor()
|
||||
runtime_storage_inst = record_processor_inst.runtime_storage_inst
|
||||
|
||||
runtime_storage_inst.set_records(record_processor_inst.process([
|
||||
{'record_type': 'commit',
|
||||
'commit_id': 'de7e8f2',
|
||||
'change_id': ['I104573'],
|
||||
'author_name': 'John Doe',
|
||||
'author_email': 'john_doe@gmail.com',
|
||||
'date': 1234567890,
|
||||
'lines_added': 25,
|
||||
'lines_deleted': 9,
|
||||
'release_name': 'havana'},
|
||||
{'record_type': 'review',
|
||||
'id': 'I104573',
|
||||
'subject': 'Fix AttributeError in Keypair._add_details()',
|
||||
'owner': {'name': 'John Doe',
|
||||
'email': 'john_doe@gmail.com',
|
||||
'username': 'john_doe'},
|
||||
'createdOn': 1385478465,
|
||||
'lastUpdated': 1385490000,
|
||||
'status': 'MERGED',
|
||||
'module': 'nova', 'branch': 'master'},
|
||||
]))
|
||||
record_processor_inst.finalize()
|
||||
|
||||
commit = runtime_storage_inst.get_by_primary_key('de7e8f2')
|
||||
self.assertEqual(1385490000, commit['date'])
|
||||
|
||||
# update records
|
||||
|
||||
def _generate_record_commit(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user