1
0
mirror of https://github.com/nix-community/home-manager synced 2024-06-01 04:23:34 +02:00
home-manager/tests/modules/programs/git/git-with-msmtp.nix
Léo DUBOIN 2e339cc6da
git: sendemail: add realName inside From field
We currently have no way of specifying the sender's name inside
the From field, making a patch sent through `git send-email` appear
as coming from "xxx@domain.com".

In this commit we make this field follow the standard `realName <email>`
format, whenever applicable.

Signed-off-by: Léo DUBOIN <leo@duboin.com>
2024-04-26 23:35:24 +02:00

47 lines
1.2 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
{
imports = [ ../../accounts/email-test-accounts.nix ];
config = {
accounts.email.accounts."hm@example.com" = {
msmtp.enable = true;
realName = mkForce "";
};
programs.git = {
enable = true;
package = pkgs.gitMinimal;
userEmail = "hm@example.com";
userName = "H. M. Test";
};
home.stateVersion = "20.09";
test.stubs.msmtp = { };
nmt.script = ''
function assertGitConfig() {
local value
value=$(${pkgs.gitMinimal}/bin/git config \
--file $TESTED/home-files/.config/git/config \
--get $1)
if [[ $value != $2 ]]; then
fail "Expected option '$1' to have value '$2' but it was '$value'"
fi
}
assertFileExists home-files/.config/git/config
assertFileContent home-files/.config/git/config \
${./git-with-msmtp-expected.conf}
assertGitConfig "sendemail.hm@example.com.from" "hm@example.com"
assertGitConfig "sendemail.hm-account.from" "H. M. Test Jr. <hm@example.org>"
assertGitConfig "sendemail.hm@example.com.smtpServer" "${pkgs.msmtp}/bin/msmtp"
assertGitConfig "sendemail.hm@example.com.envelopeSender" "auto"
'';
};
}