Skip to content

Commit

Permalink
git-credential-oauth: fix use of mkIf and add tests
Browse files Browse the repository at this point in the history
Closes #6005
  • Loading branch information
tomodachi94 authored Oct 27, 2024
1 parent 93435d2 commit 05d9bee
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 1 deletion.
3 changes: 2 additions & 1 deletion modules/programs/git-credential-oauth.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ in {
home.packages = [ cfg.package ];

programs.git.extraConfig.credential.helper = [
("${cfg.package}/bin/git-credential-oauth" + lib.mkIf cfg.extraFlags
("${cfg.package}/bin/git-credential-oauth"
+ lib.optionalString (cfg.extraFlags != [ ])
" ${lib.strings.concatStringsSep " " cfg.extraFlags}")
];
};
Expand Down
1 change: 1 addition & 0 deletions tests/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ in import nmtSrc {
./modules/programs/gh-dash
./modules/programs/git
./modules/programs/git-cliff
./modules/programs/git-credential-oauth
./modules/programs/gpg
./modules/programs/gradle
./modules/programs/granted
Expand Down
16 changes: 16 additions & 0 deletions tests/modules/programs/git-credential-oauth/basic.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{ config, pkgs, ... }:

{
programs.git-credential-oauth = { enable = true; };

programs.git = { enable = true; };

test.stubs.git-credential-oauth = { };

nmt.script = ''
assertFileExists home-files/.config/git/config
assertFileContains \
home-files/.config/git/config \
"${config.programs.git-credential-oauth.package}/bin/git-credential-oauth"
'';
}
4 changes: 4 additions & 0 deletions tests/modules/programs/git-credential-oauth/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
git-credential-oauth-basic = ./basic.nix;
git-credential-oauth-extra-flags = ./extra-flags.nix;
}
19 changes: 19 additions & 0 deletions tests/modules/programs/git-credential-oauth/extra-flags.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{ config, pkgs, ... }:

{
programs.git-credential-oauth = {
enable = true;
extraFlags = [ "-device" ];
};

programs.git = { enable = true; };

test.stubs.git-credential-oauth = { };

nmt.script = ''
assertFileExists home-files/.config/git/config
assertFileContains \
home-files/.config/git/config \
"${config.programs.git-credential-oauth.package}/bin/git-credential-oauth -device"
'';
}

0 comments on commit 05d9bee

Please sign in to comment.