fix(manifest-generate-paths): Normalize repo before using type repo (#28113)

Signed-off-by: Artem Vdovin <[email protected]>
This commit is contained in:
Artem Vdovin
2026-06-09 10:53:08 -04:00
committed by GitHub
parent df5161e55d
commit 96e2fff3f0
2 changed files with 39 additions and 0 deletions
+2
View File
@@ -3358,6 +3358,8 @@ func (s *Service) UpdateRevisionForPaths(_ context.Context, request *apiclient.U
if repo == nil {
return nil, status.Error(codes.InvalidArgument, "must pass a valid repo")
}
// Normalize the repository in the request to ensure all fields are correctly set
repo = repo.Normalize()
if len(refreshPaths) == 0 {
// Always refresh if path is not specified
+37
View File
@@ -4919,6 +4919,43 @@ func TestUpdateRevisionForPaths(t *testing.T) {
ExternalGets: 1,
ExternalSets: 1,
}},
{name: "RepositoryTypeIsEmptyChangedFilesDoNothing", fields: func() fields {
s, _, c := newServiceWithOpt(t, func(gitClient *gitmocks.Client, _ *helmmocks.Client, _ *ocimocks.Client, paths *iomocks.TempPaths) {
gitClient.EXPECT().Init().Return(nil)
gitClient.EXPECT().Fetch(mock.Anything, mock.Anything).Once().Return(nil)
gitClient.EXPECT().IsRevisionPresent("632039659e542ed7de0c170a4fcc1c571b288fc0").Once().Return(false)
gitClient.EXPECT().Checkout("632039659e542ed7de0c170a4fcc1c571b288fc0", mock.Anything, mock.Anything).Once().Return("", nil)
// fetch
gitClient.EXPECT().IsRevisionPresent("1e67a504d03def3a6a1125d934cb511680f72555").Once().Return(false)
gitClient.EXPECT().Fetch(mock.Anything, mock.Anything).Once().Return(nil)
gitClient.EXPECT().IsRevisionPresent("1e67a504d03def3a6a1125d934cb511680f72555").Once().Return(true)
gitClient.EXPECT().LsRemote("HEAD").Once().Return("632039659e542ed7de0c170a4fcc1c571b288fc0", nil)
gitClient.EXPECT().LsRemote("SYNCEDHEAD").Once().Return("1e67a504d03def3a6a1125d934cb511680f72555", nil)
paths.EXPECT().GetPath(mock.Anything).Return(".", nil)
paths.EXPECT().GetPathIfExists(mock.Anything).Return(".")
gitClient.EXPECT().Root().Return("")
gitClient.EXPECT().ChangedFiles(mock.Anything, mock.Anything).Return([]string{"app.yaml"}, nil)
}, ".")
return fields{
service: s,
cache: c,
}
}(), args: args{
ctx: t.Context(),
request: &apiclient.UpdateRevisionForPathsRequest{
Repo: &v1alpha1.Repository{Repo: "a-url.com"},
Revision: "HEAD",
SyncedRevision: "SYNCEDHEAD",
Paths: []string{"."},
},
}, want: &apiclient.UpdateRevisionForPathsResponse{
Revision: "632039659e542ed7de0c170a4fcc1c571b288fc0",
Changes: true,
}, wantErr: assert.NoError, cacheCallCount: &repositorymocks.CacheCallCounts{
ExternalRenames: 0,
ExternalGets: 1,
ExternalSets: 1,
}},
{name: "NoChangesUpdateCache", fields: func() fields {
s, _, c := newServiceWithOpt(t, func(gitClient *gitmocks.Client, _ *helmmocks.Client, _ *ocimocks.Client, paths *iomocks.TempPaths) {
gitClient.EXPECT().Init().Return(nil)