Marcus Lindblom Sonestedt avatar Marcus Lindblom Sonestedt committed 5428a2c

Allow check_hook to be used as precommit hook (fixes #19)

Comments (0)

Files changed (1)

 
 ################################################################################################
 
-def check_hook(ui, repo, hooktype, node, **kwargs):
+def check_hook(ui, repo, hooktype, **kwargs):
     '''blocks commits/changesets containing tabs or trailing whitespace'''
 
+    if hooktype == 'precommit':
+        ui.note('checkfiles: checking for tabs and/or trailing whitespace in changed files...\n')
+
+        cf = CheckFiles(ui, repo, repo[None])
+        return cf.check()
+
     if hooktype == 'pretxncommit':
         ui.note('checkfiles: checking commit for tabs or trailing whitespace...\n')
+
+        node = kwargs['node']
         cf = CheckFiles(ui, repo, repo.changectx(node))
         return cf.check()
 
         ui.note('checkfiles: checking incoming changes for tabs or trailing whitespace...\n')
         cf = CheckFiles(ui, repo, repo[None])
         fail = False
+        node = kwargs['node']
 
         for rev in revrange(repo, ['%s::' % node]):
             cf.set_changectx(repo.changectx(rev))
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.