From 621386bf4295738dbdc909b06c3345b86042e3af Mon Sep 17 00:00:00 2001 From: Zaki Shaikh Date: Wed, 22 Jan 2025 16:27:02 +0530 Subject: [PATCH] Fix GitLab MR status not updated issue on forked repo fixed issue where MR status was being created initially on MR but wasn't being updated due to wrong SourceProjectID assignment in SetClient. https://issues.redhat.com/browse/SRVKP-6100 Signed-off-by: Zaki Shaikh --- pkg/provider/gitlab/gitlab.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/provider/gitlab/gitlab.go b/pkg/provider/gitlab/gitlab.go index a4396d338a..a0c3c2461b 100644 --- a/pkg/provider/gitlab/gitlab.go +++ b/pkg/provider/gitlab/gitlab.go @@ -138,6 +138,14 @@ func (v *Provider) SetClient(_ context.Context, run *params.Run, runevent *info. } v.Token = &runevent.Provider.Token + // in a scenario where source repo is a forked and created an MR on upstream + // runevent.SourceProjectID wouldn't be 0 when SetClient is called from pac-watcher code + // because in controller SourceProjectID is set in annotation of PR and runevent.SourceProjectID + // is set before SetClient is called so its worth taking ID from runevent.SourceProjectID. + if runevent.SourceProjectID > 0 { + v.sourceProjectID = runevent.SourceProjectID + } + // if we don't have sourceProjectID (ie: incoming-webhook) then try to set // it ASAP if we can. if v.sourceProjectID == 0 && runevent.Organization != "" && runevent.Repository != "" {