Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.8, 0.8.1, and 0.8.2

commit: add message format check

checks for formatting on commit

Changeset 421941618b5c

Parent 028b6666aa59

by Trey Roessig

Changes to one file · Browse files at 421941618b5c Showing diff from parent 028b6666aa59 Diff from another changeset...

Change 1 of 2 Show Entire File hggtk/​commit.py Stacked
 
539
540
541
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
542
543
544
 
691
692
693
694
695
 
 
696
697
698
 
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
 
734
735
736
 
 
737
738
739
740
741
@@ -539,6 +539,49 @@
  _('Please enter commit message'), self).run()   self.text.grab_focus()   return False + + try: + sumlen = int(self.repo.ui.config('tortoisehg', 'summarylen', 0)) + maxlen = int(self.repo.ui.config('tortoisehg', 'messagewrap', 0)) + except (TypeError, ValueError): + Prompt(_('Error'), + _('Message format configuration error'), + self).run() + self._msg_config(None) + return + + lines = buf.get_text(buf.get_start_iter(), + buf.get_end_iter()).splitlines() + + if sumlen and len(lines[0].rstrip()) > sumlen: + resp = Confirm(_('Commit'), [], self, + _('The summary line length of %i is greater than' + ' %i.\n\nIgnore format policy and continue' + ' commit?') % + (len(lines[0].rstrip()), sumlen)).run() + if resp != gtk.RESPONSE_YES: + return False + if sumlen and len(lines) > 1 and len(lines[1].strip()): + resp = Confirm(_('Commit'), [], self, + _('The summary line is not followed by a blank' + ' line.\n\nIgnore format policy and continue' + ' commit?')).run() + if resp != gtk.RESPONSE_YES: + return False + if maxlen: + start = int(sumlen > 0) + tmp = [len(x.rstrip()) > maxlen for x in lines[start:]] + errs = [str(x[1]+start+1) for x in zip(tmp, range(len(tmp))) + if x[0]] + if errs: + resp = Confirm(_('Commit'), [], self, + _('The following lines are over the %i-' + 'character limit: %s.\n\nIgnore format' + ' policy and continue commit?') % + (maxlen, ', '.join(errs))).run() + if resp != gtk.RESPONSE_YES: + return False +   begin, end = buf.get_bounds()   self.opts['message'] = buf.get_text(begin, end)   return True @@ -691,8 +734,8 @@
    if sumlen and len(lines[0].rstrip()) > sumlen:   Prompt(_('Warning'), - _('The summary line length of %i is greater than %i' % - (len(lines[0].rstrip()), sumlen)), + _('The summary line length of %i is greater than %i') % + (len(lines[0].rstrip()), sumlen),   self).run()   if sumlen and len(lines) > 1 and len(lines[1].strip()):   Prompt(_('Warning'),