Skip to content

Commit

Permalink
fix(notifs): check for commit hash length
Browse files Browse the repository at this point in the history
  • Loading branch information
smrz2001 committed Jul 26, 2023
1 parent 3a6e489 commit 41e860b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cd/manager/notifs/discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ const (

const DiscordPacing = 2 * time.Second

const ShaTagLength = 12

var _ manager.Notifs = &JobNotifs{}

type JobNotifs struct {
Expand Down Expand Up @@ -269,9 +271,9 @@ func (n JobNotifs) getDeployHashes(jobState manager.JobState) string {
}

func (n JobNotifs) getComponentMsg(component manager.DeployComponent, commitHashes map[manager.DeployComponent]string) string {
if commitHash, found := commitHashes[component]; found {
if commitHash, found := commitHashes[component]; found && (len(commitHash) >= ShaTagLength) {
repo := manager.ComponentRepo(component)
return fmt.Sprintf("[%s (%s)](https://github.com/%s/%s/commit/%s)", repo, commitHash[:12], manager.GitHubOrg, repo, commitHash)
return fmt.Sprintf("[%s (%s)](https://github.com/%s/%s/commit/%s)", repo, commitHash[:ShaTagLength], manager.GitHubOrg, repo, commitHash)
}
return ""
}
Expand Down

0 comments on commit 41e860b

Please sign in to comment.