-
Notifications
You must be signed in to change notification settings - Fork 6.4k
feat(hydrator): Commit message templating (#23679) #24204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
crenshaw-dev
merged 31 commits into
argoproj:master
from
pbhatnagar-oss:commit-message-templating
Sep 3, 2025
+600
−26
Merged
Changes from 18 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
a20a48e
initial commit.. wip
pbhatnagar-oss c2ba18c
adding unit tests
pbhatnagar-oss de7f06f
more unit tests and comments
pbhatnagar-oss c8c3bd0
clean up, adding more comments
pbhatnagar-oss 94e0b10
Merge branch 'master' of github.com:pbhatnagar-oss/argo-cd into commi…
pbhatnagar-oss 4d143a9
updating the template to strongly typed. reverting changes to generat…
pbhatnagar-oss 2d1a17d
Update controller/hydrator/hydrator.go
pbhatnagar-oss 328ebfd
Update controller/hydrator/hydrator.go
pbhatnagar-oss 9f2bbb9
addressing review-comments and codegen
pbhatnagar-oss 991c0c6
rename symbol and adjust comments
pbhatnagar-oss 4b2fb40
please lint
pbhatnagar-oss 06125ce
adjust template and test (#1)
crenshaw-dev 71a85b0
review changes, fix e2e test and update documentation
pbhatnagar-oss b7f6e2e
Update docs/user-guide/source-hydrator.md
pbhatnagar-oss 3fdb975
Merge branch 'master' of github.com:pbhatnagar-oss/argo-cd into commi…
pbhatnagar-oss b566ce6
Merge branch 'commit-message-templating' of github.com:pbhatnagar-oss…
pbhatnagar-oss 4840a39
review comments
pbhatnagar-oss eedfa33
fix unit test
pbhatnagar-oss 2420e4b
Update docs/operator-manual/argocd-cm.yaml
pbhatnagar-oss 66965ca
Update util/settings/settings.go
pbhatnagar-oss d655a91
remove the template from argocd-cm in the favor of default
pbhatnagar-oss d7697ff
remove the template from argocd-cm in the favor of default
pbhatnagar-oss 46d5a10
Merge branch 'commit-message-templating' of github.com:pbhatnagar-oss…
pbhatnagar-oss 267d9ab
Merge branch 'commit-message-templating' of github.com:pbhatnagar-oss…
pbhatnagar-oss 1793160
Merge branch 'commit-message-templating' of github.com:pbhatnagar-oss…
pbhatnagar-oss b2b9cbc
fix unit test to accommodate the change to template
pbhatnagar-oss abac470
Update docs/user-guide/source-hydrator.md
pbhatnagar-oss c31eeed
Update docs/operator-manual/argocd-cm.yaml
pbhatnagar-oss 7d60fe4
Update manifests/base/config/argocd-cm.yaml
pbhatnagar-oss 343d40f
codegen
pbhatnagar-oss 416fca1
Merge branch 'master' of github.com:pbhatnagar-oss/argo-cd into commi…
pbhatnagar-oss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,8 +13,15 @@ import ( | |
"github.com/argoproj/argo-cd/v3/controller/hydrator/mocks" | ||
"github.com/argoproj/argo-cd/v3/controller/hydrator/types" | ||
"github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1" | ||
"github.com/argoproj/argo-cd/v3/util/settings" | ||
) | ||
|
||
var message = `testn | ||
Argocd-reference-commit-repourl: https://github.com/test/argocd-example-apps | ||
Argocd-reference-commit-author: Argocd-reference-commit-author | ||
Argocd-reference-commit-subject: testhydratormd | ||
Signed-off-by: testUser <[email protected]>` | ||
|
||
func Test_appNeedsHydration(t *testing.T) { | ||
t.Parallel() | ||
|
||
|
@@ -167,3 +174,80 @@ func Test_getRelevantAppsForHydration_RepoURLNormalization(t *testing.T) { | |
require.NoError(t, err) | ||
assert.Len(t, relevantApps, 2, "Expected both apps to be considered relevant despite URL differences") | ||
} | ||
|
||
func TestHydrator_getTemplatedCommitMessage(t *testing.T) { | ||
references := make([]v1alpha1.RevisionReference, 0) | ||
revReference := v1alpha1.RevisionReference{ | ||
Commit: &v1alpha1.CommitMetadata{ | ||
Author: "testAuthor", | ||
Subject: "test", | ||
RepoURL: "https://github.com/test/argocd-example-apps", | ||
SHA: "3ff41cc5247197a6caf50216c4c76cc29d78a97c", | ||
}, | ||
} | ||
references = append(references, revReference) | ||
type args struct { | ||
repoURL string | ||
revision string | ||
dryCommitMetadata *v1alpha1.RevisionMetadata | ||
template string | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
want string | ||
wantErr bool | ||
}{ | ||
{ | ||
name: "test template", | ||
args: args{ | ||
repoURL: "https://github.com/test/argocd-example-apps", | ||
revision: "3ff41cc5247197a6caf50216c4c76cc29d78a97d", | ||
dryCommitMetadata: &v1alpha1.RevisionMetadata{ | ||
Author: "test [email protected]", | ||
Date: &metav1.Time{ | ||
Time: metav1.Now().Time, | ||
}, | ||
Message: message, | ||
References: references, | ||
}, | ||
template: settings.CommitMessageTemplate, | ||
}, | ||
want: `testn | ||
Argocd-reference-commit-repourl: https://github.com/test/argocd-example-apps | ||
Argocd-reference-commit-author: Argocd-reference-commit-author | ||
Argocd-reference-commit-subject: testhydratormd | ||
Signed-off-by: testUser <[email protected]> | ||
|
||
Co-authored-by: testAuthor | ||
Co-authored-by: test [email protected] | ||
`, | ||
}, | ||
{ | ||
name: "test empty template", | ||
args: args{ | ||
repoURL: "https://github.com/test/argocd-example-apps", | ||
revision: "3ff41cc5247197a6caf50216c4c76cc29d78a97d", | ||
dryCommitMetadata: &v1alpha1.RevisionMetadata{ | ||
Author: "test [email protected]", | ||
Date: &metav1.Time{ | ||
Time: metav1.Now().Time, | ||
}, | ||
Message: message, | ||
References: references, | ||
}, | ||
}, | ||
want: "", | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got, err := getTemplatedCommitMessage(tt.args.repoURL, tt.args.revision, tt.args.template, tt.args.dryCommitMetadata) | ||
if (err != nil) != tt.wantErr { | ||
t.Errorf("Hydrator.getHydratorCommitMessage() error = %v, wantErr %v", err, tt.wantErr) | ||
return | ||
} | ||
assert.Equal(t, tt.want, got) | ||
}) | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.