1{ buildPythonApplication
2, charset-normalizer
3, colorama
4, commitizen
5, decli
6, fetchFromGitHub
7, git
8, jinja2
9, lib
10, packaging
11, poetry-core
12, py
13, pytest-freezer
14, pytest-mock
15, pytest-regressions
16, pytestCheckHook
17, pyyaml
18, questionary
19, termcolor
20, testers
21, tomlkit
22, typing-extensions
23, argcomplete
24, nix-update-script
25, pre-commit
26}:
27
28buildPythonApplication rec {
29 pname = "commitizen";
30 version = "2.42.1";
31
32 src = fetchFromGitHub {
33 owner = "commitizen-tools";
34 repo = pname;
35 rev = "v${version}";
36 hash = "sha256-lrZfMqmslwx3B2WkvFosm3EmCHgpZEA/fOzR6UYf6f8=";
37 };
38
39 format = "pyproject";
40
41 nativeBuildInputs = [ poetry-core ];
42
43 postPatch = ''
44 substituteInPlace pyproject.toml \
45 --replace 'charset-normalizer = "^2.1.0"' 'charset-normalizer = "*"' \
46 --replace 'argcomplete = ">=1.12.1,<2.1"' 'argcomplete = ">=1.12.1"'
47 '';
48
49 propagatedBuildInputs = [
50 charset-normalizer
51 termcolor
52 questionary
53 colorama
54 decli
55 tomlkit
56 jinja2
57 pyyaml
58 argcomplete
59 typing-extensions
60 packaging
61 ];
62
63 doCheck = true;
64
65 nativeCheckInputs = [
66 pre-commit
67 py
68 pytestCheckHook
69 pytest-freezer
70 pytest-mock
71 pytest-regressions
72 argcomplete
73 git
74 ];
75
76 # the tests require a functional git installation
77 # which requires a valid HOME directory.
78 preCheck = ''
79 export HOME="$(mktemp -d)"
80
81 git config --global user.name "Nix Builder"
82 git config --global user.email "nix-builder@nixos.org"
83 git init .
84 '';
85
86 # NB: These tests require complex GnuPG setup
87 disabledTests = [
88 "test_bump_minor_increment_signed"
89 "test_bump_minor_increment_signed_config_file"
90 "test_bump_on_git_with_hooks_no_verify_enabled"
91 "test_bump_on_git_with_hooks_no_verify_disabled"
92 "test_bump_pre_commit_changelog"
93 "test_bump_pre_commit_changelog_fails_always"
94 "test_get_commits_with_signature"
95 # fatal: not a git repository (or any of the parent directories): .git
96 "test_commitizen_debug_excepthook"
97 ];
98
99 passthru = {
100 tests.version = testers.testVersion {
101 package = commitizen;
102 command = "cz version";
103 };
104 updateScript = nix-update-script { };
105 };
106
107 meta = with lib; {
108 description = "Tool to create committing rules for projects, auto bump versions, and generate changelogs";
109 homepage = "https://github.com/commitizen-tools/commitizen";
110 changelog = "https://github.com/commitizen-tools/commitizen/blob/v${version}/CHANGELOG.md";
111 license = licenses.mit;
112 maintainers = with maintainers; [ lovesegfault anthonyroussel ];
113 };
114}