1

I'm trying to write an Atlassian Stash pre-receive hook that will check if pushed code's python files comply with the python PEP-8 style convention. There are already two tools that do exactly what I want-- pep8 and yapf.

However, I do not know how to integrate these tools to be used in a Stash pre-receive hook, which has to be written in Java. If I'm writing a Stash pre-receive hook in Java, how can I make use of pep8 and yapf?

user2946797
  • 171
  • 2
  • 11
  • I am essentially asking for advice on how to design my code. I know I have to write my code in Java, and it has to implement the [PreReceiveRepositoryHook](https://developer.atlassian.com/static/javadoc/stash/3.9.1/spi/reference/com/atlassian/stash/hook/repository/PreReceiveRepositoryHook.html) interface. The method `onReceive` should return true if the pushed code's python files comply with PEP-8, and false if not. There is already a command-line tool called [pep8](https://pypi.python.org/pypi/pep8) to check if a python file complies with PEP-8. How can I use this command-line tool in Java? – user2946797 May 28 '15 at 00:49

1 Answers1

0

One approach you could try is use this external hooks add-on which can then run whatever scripts you need and return a result.

That said, I'd suggest considering also whether pre-receive is the right time to be making users wait, and possibly have to go back and fix their work. An alternative is a combination of pre-commit hooks on the client side (admittedly not always easy to enforce), and using an asynchronous process (using a build system such as Bamboo) to run checks. The former gives developers more immediate feedback, and the latter works as a safety net without being super-strict about it. In other words, you might be able to enforce this more through process (and the right cultural encouragement to do the right thing) than through strict tool enforcement. YMMV

Rog
  • 4,075
  • 2
  • 24
  • 35