mirror of
https://github.com/rpm-software-management/tito.git
synced 2025-02-23 12:12:47 +00:00
provide config for editorconfig plugins
* If a dev adds an editorconfig plugin to their editor, automatically configure their editor for code style. * Specify 4-space softtabs so new code will be compatible with Python 3. * Put the same settings in .gitattributes so git diff highlights whitespace errors.
This commit is contained in:
parent
47a5cda981
commit
3be5a2d1b6
3 changed files with 74 additions and 4 deletions
23
.editorconfig
Normal file
23
.editorconfig
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
; Unify the coding style for different editors and IDEs.
|
||||||
|
; Plugins are available for emacs, vim, gedit, textmate, and more
|
||||||
|
; at http://editorconfig.org/#download
|
||||||
|
;
|
||||||
|
; See http://editorconfig.org or https://github.com/editorconfig/
|
||||||
|
;
|
||||||
|
; If you change a setting in this file,
|
||||||
|
; you should also change .gitattributes
|
||||||
|
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.py]
|
||||||
|
indent_size = 4
|
||||||
|
|
||||||
|
[*.yml]
|
||||||
|
indent_size = 2
|
14
.gitattributes
vendored
Normal file
14
.gitattributes
vendored
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
######################################################################
|
||||||
|
# gitattributes(5) describes the format and usage of this file.
|
||||||
|
#
|
||||||
|
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
|
||||||
|
# http://git-scm.com/book/ch7-2.html
|
||||||
|
# http://urbanautomaton.com/blog/2011/07/28/git-grep-and-language-specific-diffs/
|
||||||
|
# https://help.github.com/articles/dealing-with-line-endings
|
||||||
|
######################################################################
|
||||||
|
#
|
||||||
|
# If you change a setting here,
|
||||||
|
# you should also change .editorconfig
|
||||||
|
#
|
||||||
|
*.py diff=python text eol=lf whitespace="trailing-space,space-before-tab,tab-in-indent,blank-at-eof,tabwidth=4"
|
||||||
|
*.yml text eol=lf whitespace="trailing-space,space-before-tab,tab-in-indent,blank-at-eof,tabwidth=2"
|
41
HACKING
41
HACKING
|
@ -1,8 +1,22 @@
|
||||||
To run all tests, install the python-nose package and from the root of the
|
Hacking
|
||||||
project:
|
=======
|
||||||
|
|
||||||
./runtests.py
|
Python versions
|
||||||
|
---------------
|
||||||
|
|
||||||
|
Tito supports Python versions 2.4 (RHEL 5) and up.
|
||||||
|
See http://docs.python.org/dev/howto/pyporting.html
|
||||||
|
and http://python3porting.com/differences.html
|
||||||
|
for tips on writing portable Python code.
|
||||||
|
|
||||||
|
|
||||||
|
Tests
|
||||||
|
-----
|
||||||
|
|
||||||
|
To run all tests, install the python-nose and python3-nose
|
||||||
|
packages, then from the root of the project:
|
||||||
|
|
||||||
|
python ./runtests.py
|
||||||
|
|
||||||
|
|
||||||
When developing code for tito there are a couple ways you can test:
|
When developing code for tito there are a couple ways you can test:
|
||||||
|
@ -10,7 +24,9 @@ When developing code for tito there are a couple ways you can test:
|
||||||
"bin/tito-dev" is a script that will run code from the local checkout
|
"bin/tito-dev" is a script that will run code from the local checkout
|
||||||
rather than what is installed on the system.
|
rather than what is installed on the system.
|
||||||
|
|
||||||
And of course, you can always use the installed tito to replace itself with a test build of the latest *committed* code in your git HEAD.
|
And of course, you can always use the installed tito to replace
|
||||||
|
itself with a test build of the latest *committed* code in your
|
||||||
|
git HEAD.
|
||||||
|
|
||||||
tito build --rpm --test -i
|
tito build --rpm --test -i
|
||||||
|
|
||||||
|
@ -19,3 +35,20 @@ If you screw anything up inside tito itself, you can just:
|
||||||
rpm -e tito
|
rpm -e tito
|
||||||
yum install tito
|
yum install tito
|
||||||
|
|
||||||
|
|
||||||
|
Code style
|
||||||
|
----------
|
||||||
|
|
||||||
|
Python3 does not allow mixing tabs and spaces for indentation.
|
||||||
|
http://docs.python.org/3.3/reference/lexical_analysis.html
|
||||||
|
|
||||||
|
You can force your editor to do the right thing by installing
|
||||||
|
a plugin for your editor from http://editorconfig.org/#download
|
||||||
|
|
||||||
|
For example, add the EditorConfig plugin for vim like this:
|
||||||
|
|
||||||
|
cd /tmp/
|
||||||
|
wget https://github.com/editorconfig/editorconfig-vim/archive/master.zip
|
||||||
|
unzip master.zip
|
||||||
|
mkdir ~/.vim
|
||||||
|
cp -r editorconfig-vim-master/* ~/.vim/
|
||||||
|
|
Loading…
Add table
Reference in a new issue