← Back to team overview

widelands-dev team mailing list archive

Re: [Merge] lp:~widelands-dev/widelands/automate_clang-format into lp:widelands

 

> Can this be added to the bunnybot merge command once we have this in trunk? I'm thinking bzr merge, clang-format, bzr commit here.

Yes, it probably can. If I can figure out how to install clang-format on the buildbot. I'll have a look.

A couple of nits inlined.

Diff comments:

> === added file 'utils/run_clang_format.py'
> --- utils/run_clang_format.py	1970-01-01 00:00:00 +0000
> +++ utils/run_clang_format.py	2016-12-01 18:07:34 +0000
> @@ -0,0 +1,42 @@
> +#!/usr/bin/env python
> +# -*- coding: utf-8 -*-
> +
> +
> +"""This script runs clang-format over src and all its subdirectories."""
> +
> +import argparse
> +import os
> +import sys
> +from subprocess import call
> +
> +
> +def parse_args():
> +    p = argparse.ArgumentParser(description='Run clang-format over the code base.'

move closing ) up?

> +                                )
> +    return p.parse_args()
> +
> +
> +def find_cplusplus_files():
> +    for (dirpath, _, filenames) in os.walk('./src'):
> +        for filename in filenames:
> +            if os.path.splitext(filename)[-1].lower() == '.cc' or os.path.splitext(filename)[-1].lower() == '.h':

if os.path.splitext(filename)[-1].lower() in ['.cc', '.h']

> +                yield os.path.join(dirpath, filename)
> +
> +
> +def main():
> +    parse_args()
> +
> +    if not os.path.isdir('src') or not os.path.isdir('utils'):
> +        print('CWD is not the root of the repository.')
> +        return 1
> +
> +    sys.stdout.write('Running clang-format ')
> +    for filename in find_cplusplus_files():
> +        sys.stdout.write('.')
> +        sys.stdout.flush()
> +        call(['clang-format', '-i', filename])
> +    print '\nFormatting finished.'
> +    return 0
> +
> +if __name__ == '__main__':
> +    sys.exit(main())


-- 
https://code.launchpad.net/~widelands-dev/widelands/automate_clang-format/+merge/312287
Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/automate_clang-format.


References