Skip to content

Commit

Permalink
Fix GitLab MR not updated issue on forked repository
Browse files Browse the repository at this point in the history
fixed GitLan issue where MR status was created initially but wasn't
being updated on finish and was throwing error `404 not found` due to
wrong SourceProjectID assignment in SetClient.

https://issues.redhat.com/browse/SRVKP-6100

Signed-off-by: Zaki Shaikh <zashaikh@redhat.com>
  • Loading branch information
zakisk authored and chmouel committed Jan 22, 2025
1 parent d05d18b commit 1aecd8a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/provider/gitlab/gitlab.go
Original file line number Diff line number Diff line change
@@ -138,6 +138,15 @@ func (v *Provider) SetClient(_ context.Context, run *params.Run, runevent *info.
}
v.Token = &runevent.Provider.Token

// In a scenario where the source repository is forked and a merge request (MR) is created on the upstream
// repository, runevent.SourceProjectID will not be 0 when SetClient is called from the pac-watcher code.
// This is because, in the controller, SourceProjectID is set in the annotation of the pull request,
// and runevent.SourceProjectID is set before SetClient is called. Therefore, we need to take
// the 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 != "" {

0 comments on commit 1aecd8a

Please sign in to comment.