106
121
return (count, result, all_verifiable)
108
123
def valid_commits_message(self, count):
109
return i18n.gettext("{0} commits with valid signatures").format(
124
return i18n.gettext(u"{0} commits with valid signatures").format(
110
125
count[SIGNATURE_VALID])
112
127
def unknown_key_message(self, count):
113
return i18n.ngettext("{0} commit with unknown key",
114
"{0} commits with unknown keys",
128
return i18n.ngettext(u"{0} commit with unknown key",
129
u"{0} commits with unknown keys",
115
130
count[SIGNATURE_KEY_MISSING]).format(
116
131
count[SIGNATURE_KEY_MISSING])
118
133
def commit_not_valid_message(self, count):
119
return i18n.ngettext("{0} commit not valid",
120
"{0} commits not valid",
134
return i18n.ngettext(u"{0} commit not valid",
135
u"{0} commits not valid",
121
136
count[SIGNATURE_NOT_VALID]).format(
122
137
count[SIGNATURE_NOT_VALID])
124
139
def commit_not_signed_message(self, count):
125
return i18n.ngettext("{0} commit not signed",
126
"{0} commits not signed",
140
return i18n.ngettext(u"{0} commit not signed",
141
u"{0} commits not signed",
127
142
count[SIGNATURE_NOT_SIGNED]).format(
128
143
count[SIGNATURE_NOT_SIGNED])
157
177
def _command_line(self):
158
return [self._config.gpg_signing_command(), '--clearsign']
179
return [self._config.gpg_signing_command(), '--clearsign', '-u',
180
self._config.gpg_signing_key()]
160
182
def __init__(self, config):
161
183
self._config = config
261
283
if isinstance(acceptable_keys_config, unicode):
262
284
acceptable_keys_config = str(acceptable_keys_config)
263
285
except UnicodeEncodeError:
286
#gpg Context.keylist(pattern) does not like unicode
264
287
raise errors.BzrCommandError('Only ASCII permitted in option names')
266
289
if acceptable_keys_config is not None:
283
306
"No GnuPG key results for pattern: {}"
284
307
).format(pattern))
286
def do_verifications(self, revisions, repository):
309
def do_verifications(self, revisions, repository,
310
process_events_callback=None):
287
311
"""do verifications on a set of revisions
289
313
:param revisions: list of revision ids to verify
290
314
:param repository: repository object
315
:param process_events_callback: method to call for GUI frontends that
316
want to keep their UI refreshed
292
318
:return: count dictionary of results of each type,
293
319
result list for each revision,
306
332
count[verification_result] += 1
307
333
if verification_result != SIGNATURE_VALID:
308
334
all_verifiable = False
335
if process_events_callback is not None:
336
process_events_callback()
309
337
return (count, result, all_verifiable)
311
339
def verbose_valid_message(self, result):
317
345
signers[uid] += 1
319
347
for uid, number in signers.items():
320
result.append( i18n.ngettext("{0} signed {1} commit",
321
"{0} signed {1} commits",
348
result.append( i18n.ngettext(u"{0} signed {1} commit",
349
u"{0} signed {1} commits",
322
350
number).format(uid, number) )
334
362
signers[authors] += 1
336
364
for authors, number in signers.items():
337
result.append( i18n.ngettext("{0} commit by author {1}",
338
"{0} commits by author {1}",
365
result.append( i18n.ngettext(u"{0} commit by author {1}",
366
u"{0} commits by author {1}",
339
367
number).format(number, authors) )
350
378
signers[authors] += 1
352
380
for authors, number in signers.items():
353
result.append( i18n.ngettext("{0} commit by author {1}",
354
"{0} commits by author {1}",
381
result.append( i18n.ngettext(u"{0} commit by author {1}",
382
u"{0} commits by author {1}",
355
383
number).format(number, authors) )
364
392
signers[fingerprint] += 1
366
394
for fingerprint, number in signers.items():
367
result.append( i18n.ngettext("Unknown key {0} signed {1} commit",
368
"Unknown key {0} signed {1} commits",
395
result.append( i18n.ngettext(u"Unknown key {0} signed {1} commit",
396
u"Unknown key {0} signed {1} commits",
369
397
number).format(fingerprint, number) )
372
400
def valid_commits_message(self, count):
373
401
"""returns message for number of commits"""
374
return i18n.gettext("{0} commits with valid signatures").format(
402
return i18n.gettext(u"{0} commits with valid signatures").format(
375
403
count[SIGNATURE_VALID])
377
405
def unknown_key_message(self, count):
378
406
"""returns message for number of commits"""
379
return i18n.ngettext("{0} commit with unknown key",
380
"{0} commits with unknown keys",
407
return i18n.ngettext(u"{0} commit with unknown key",
408
u"{0} commits with unknown keys",
381
409
count[SIGNATURE_KEY_MISSING]).format(
382
410
count[SIGNATURE_KEY_MISSING])
384
412
def commit_not_valid_message(self, count):
385
413
"""returns message for number of commits"""
386
return i18n.ngettext("{0} commit not valid",
387
"{0} commits not valid",
414
return i18n.ngettext(u"{0} commit not valid",
415
u"{0} commits not valid",
388
416
count[SIGNATURE_NOT_VALID]).format(
389
417
count[SIGNATURE_NOT_VALID])
391
419
def commit_not_signed_message(self, count):
392
420
"""returns message for number of commits"""
393
return i18n.ngettext("{0} commit not signed",
394
"{0} commits not signed",
421
return i18n.ngettext(u"{0} commit not signed",
422
u"{0} commits not signed",
395
423
count[SIGNATURE_NOT_SIGNED]).format(
396
424
count[SIGNATURE_NOT_SIGNED])