Fix an issue where a mail would be sent to the same recipient twice

This commit is contained in:
Michael de Wit 2017-01-24 14:39:13 +01:00
parent c9430e82e6
commit ca0f94098b
2 changed files with 11 additions and 2 deletions

View file

@ -18,7 +18,7 @@ func main() {
app.Name = "email plugin"
app.Usage = "email plugin"
app.Action = run
app.Version = "2.0.1"
app.Version = "2.0.2"
app.Flags = []cli.Flag{
// Plugin environment
cli.StringFlag{

View file

@ -110,7 +110,16 @@ func (p Plugin) Exec() error {
var dialer *gomail.Dialer
if !p.Config.RecipientsOnly {
p.Config.Recipients = append(p.Config.Recipients, p.Commit.Author.Email)
exists := false
for _, recipient := range p.Config.Recipients {
if recipient == p.Commit.Author.Email {
exists = true
}
}
if !exists {
p.Config.Recipients = append(p.Config.Recipients, p.Commit.Author.Email)
}
}
if p.Config.Username == "" && p.Config.Password == "" {