[PATCHES] Sprinting on rpkg during PyCon-Fr

Mathieu Bridon bochecha at fedoraproject.org
Wed Oct 29 12:56:58 UTC 2014


>From Saturday to Tuesday was PyCon-Fr, here in Lyon, so I used the time to
hack a bit on rpkg.

The result is a pretty big changeset:

 .gitignore                       |   1 +
 setup.cfg                        |   5 +
 setup.py                         |  38 ++-----
 src/pyrpkg/__init__.py           | 357 +++++++++++++++++++++++++++++++-------------------------------
 src/pyrpkg/cli.py                | 976 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------------------------------------------------------------------------------------------
 src/rpkg_man_page.py             |  11 +-
 test/commands/__init__.py        | 110 ++++++++++++++++++++
 test/commands/test_add_tag.py    | 156 ++++++++++++++++++++++++++++
 test/commands/test_clone.py      |  88 ++++++++++++++++
 test/commands/test_delete_tag.py |  51 +++++++++
 test/commands/test_list_tag.py   | 159 ++++++++++++++++++++++++++++
 test/test_gitgnore.py            |  83 +++++++++++++++
 12 files changed, 1274 insertions(+), 761 deletions(-)

Now, out of these 1274 insertions, 647 are new unit tests. So if you remove
that from the count, the overall diff stat is rather:

  6 files changed,  627 insertions(+), 761 deletions(-)

That's right, keeping the same features, fixing a couple of bugs, and making
us almost entirely Flake8-compliant, I'm still removing more 100 lines of
code. Not bad. :)

Speaking of Flake8 compliance, the remaining problems are all stuff I'd rather
not touch right now, in the middle of what are mostly trivial changes. We'll
get there at some point, though.

To make review easier, here's an outline of what the patches do.

* [PATCH 01/20] Some more PEP8
* [PATCH 02/20] Remove unused import

Just some trivial changes to the setup.py script, to make the next commit
easier to review.

* [PATCH 03/20] tests: Use nose

This makes use of the awesome 'nose' testing library, removing some home-grown
code, and adding a pretty nice feature: a report of the code coverage of the
unit tests.

* [PATCH 04/20] tests: Ensure proper functioning of GitIgnore
* [PATCH 05/20] gitignore: We're not modified any more after we wrote
* [PATCH 06/20] gitignore: Make sure each line ends with a \n

These add some unit tests for our handling of .gitignore files, which actually
found 2 bugs in the code. Hurray for unit tests!

* [PATCH 07/20] tests: Ensure functioning of Commands.clone
* [PATCH 08/20] tests: Factor out some code

This sets up the necessary conditions for easily testing all the interactions
with Git repositories, and actually tests the clone command.

* [PATCH 09/20] tests: Ensure proper functioning of Commands.add_tag
* [PATCH 10/20] add_tag: Run the tag command in the right directory

These add some unit tests for the add_tag command, which actually found a bug
in the code. One more victory for unit tests!

* [PATCH 11/20] tests: Ensure functioning of Commands.delete_tag
* [PATCH 12/20] delete_tag: Stop executing a command

This adds some unit tests for the delete_tag command.

And once it is tested, it is easy to move away from subprocessing the git cli,
which makes the code nicer and avoids the overhead of forking child processes.
Plus, pyrpkg is a library, and it's generally a terrible idea to subprocess
command line tools inside a library.

* [PATCH 13/20] list_tags: Fix the docstring
* [PATCH 14/20] list_tags: Stop executing a command
* [PATCH 15/20] tests: Ensure functioning of Commands.list_tag

These greatly improve the list_tag command.

The second patch is in fact necessary to make the method testable.

* [PATCH 16/20] Fix typo
* [PATCH 17/20] Simplify some code

Just two trivial changes I came up with while idly reading the source code.

* [PATCH 18/20] Fix some flake8 issues
* [PATCH 19/20] Fix some more Flake8 issues
* [PATCH 20/20] Massive Flake8 fix

These are pretty massive patches, but they are worth it: they make the code
easier to read and "get into" for newcomers by following standard Python
conventions, removing unused variables and imports, etc...

All in all, they even remove lines of code. The diffstat for just these 3
changes is: 3 files changed, 577 insertions(+), 709 deletions(-)


More information about the rel-eng mailing list