Bożydar Sobczak avatar Bożydar Sobczak committed 1e8c30a

Smelly change message logic added

Comments (0)

Files changed (2)

 vim_cmd = (re.compile(r':(w|wq|q|x)$', re.M), 'vim exit command')
 windows_nl = (re.compile(r'\r'), 'Windows newline')
 merge_marker = (re.compile(r'^(>>>>>>>|<<<<<<<)'), 'merge marker')
+imported_patch = (re.compile(r'^imported patch.*'), 'message from MQ')
 
 # the master dict maps glob patterns to a list of smelly patterns
 SMELLY_STUFF = {
     '*.py': [print_stmt, zero_div, set_trace],
     '*': [vim_cmd, merge_marker],
 }
+SMELLY_MESSAGE_STUFF = [imported_patch]
 
 if os.name != 'nt':
     # only pick on Windows newlines if not on Windows
 
     revs = utilmodule.revpair(repo, None)
     changes = repo.status(*revs, match=match)
+    change_message = opts['message']
     if changes[1]:
         # check if any added files would be ignored
         for fn in changes[1]:
             if repo.dirstate._ignore(fn):
                 ui.warn('File %r added, but it would be ignored.\n' % fn)
                 smelly_count += 1
+    
+    for rex, reason in SMELLY_MESSAGE_STUFF:
+        if rex.match(change_message):
+            ui.warn('Smelly change message (%s)\n' % reason)
+            smelly_count += 1
+            
     diff = patch.diff(repo, *revs, match=match)
     smellies = []
     for chunk in diff:
 echo "1/0" >> file.txt
 $HG commit -vm "Blah, blah." || die "commit failed"
 
+msg "Trying to commit file.txt with smelling change message. codesmell should complain."
+echo "1/0" >> file.txt
+echo | $HG commit -vm "imported patch blah-blah"
+[ $? -eq 1 ] || die "codesmell didn't exit with error"
+$HG revert -a || die "revert failed"
+
 msg "Removing test repository."
 cd ..
 rm -r repo
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.