1{
2 lib,
3 stdenv,
4 buildGoModule,
5 fetchFromGitHub,
6 installShellFiles,
7 git,
8 testers,
9 git-town,
10 makeWrapper,
11 writableTmpDirAsHomeHook,
12}:
13
14buildGoModule rec {
15 pname = "git-town";
16 version = "21.3.0";
17
18 src = fetchFromGitHub {
19 owner = "git-town";
20 repo = "git-town";
21 tag = "v${version}";
22 hash = "sha256-G1xeMOKZ1EKCZXqC2fJEUa5PeWUGknv0zew7rjAXqkM=";
23 };
24
25 vendorHash = null;
26
27 nativeBuildInputs = [
28 installShellFiles
29 makeWrapper
30 ];
31
32 buildInputs = [ git ];
33
34 ldflags =
35 let
36 modulePath = "github.com/git-town/git-town/v${lib.versions.major version}";
37 in
38 [
39 "-s"
40 "-w"
41 "-X ${modulePath}/src/cmd.version=v${version}"
42 "-X ${modulePath}/src/cmd.buildDate=nix"
43 ];
44
45 nativeCheckInputs = [
46 git
47 writableTmpDirAsHomeHook
48 ];
49
50 preCheck = ''
51 # this runs tests requiring local operations
52 rm main_test.go
53 '';
54
55 checkFlags =
56 let
57 # Disable tests requiring local operations
58 skippedTests = [
59 "TestGodog"
60 "TestMockingRunner/MockCommand"
61 "TestMockingRunner/MockCommitMessage"
62 "TestMockingRunner/QueryWith"
63 "TestTestCommands/CreateChildFeatureBranch"
64 ];
65 in
66 [ "-skip=^${builtins.concatStringsSep "$|^" skippedTests}$" ];
67
68 postInstall =
69 lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
70 installShellCompletion --cmd git-town \
71 --bash <($out/bin/git-town completions bash) \
72 --fish <($out/bin/git-town completions fish) \
73 --zsh <($out/bin/git-town completions zsh)
74 ''
75 + ''
76 wrapProgram $out/bin/git-town --prefix PATH : ${lib.makeBinPath [ git ]}
77 '';
78
79 passthru.tests.version = testers.testVersion {
80 package = git-town;
81 command = "git-town --version";
82 inherit version;
83 };
84
85 meta = {
86 description = "Generic, high-level git support for git-flow workflows";
87 homepage = "https://www.git-town.com/";
88 license = lib.licenses.mit;
89 maintainers = with lib.maintainers; [
90 allonsy
91 gabyx
92 ];
93 mainProgram = "git-town";
94 };
95}