@@ -157,7 +157,7 @@ func CreateUserRepository(ctx context.Context, gc gitprovider.Client, domain str
157157}
158158
159159// CreateOrganizationPullRequest creates a pull-request for an organization owned repository.
160- func CreateOrganizationPullRequest (ctx context.Context , gc gitprovider.Client , domain , branch string , spec deliveryv1alpha1.PullRequestTemplate , repository mpasv1alpha1.Repository ) error {
160+ func CreateOrganizationPullRequest (ctx context.Context , gc gitprovider.Client , domain , branch string , spec deliveryv1alpha1.PullRequestTemplate , repository mpasv1alpha1.Repository ) ( int , error ) {
161161 // find the repository
162162 repo , err := gc .OrgRepositories ().Get (ctx , gitprovider.OrgRepositoryRef {
163163 OrganizationRef : gitprovider.OrganizationRef {
@@ -167,7 +167,7 @@ func CreateOrganizationPullRequest(ctx context.Context, gc gitprovider.Client, d
167167 RepositoryName : repository .GetName (),
168168 })
169169 if err != nil {
170- return fmt .Errorf ("failed to find organization repository: %w" , err )
170+ return - 1 , fmt .Errorf ("failed to find organization repository: %w" , err )
171171 }
172172
173173 var (
@@ -190,17 +190,17 @@ func CreateOrganizationPullRequest(ctx context.Context, gc gitprovider.Client, d
190190
191191 pr , err := repo .PullRequests ().Create (ctx , title , branch , base , description )
192192 if err != nil {
193- return fmt .Errorf ("failed to create pull request: %w" , err )
193+ return - 1 , fmt .Errorf ("failed to create pull request: %w" , err )
194194 }
195195
196196 logger := log .FromContext (ctx )
197197 logger .Info ("created pull request for organization repository" , "organization" , repository .Spec .Owner , "pull-request" , pr .Get ().Number )
198198
199- return nil
199+ return pr . Get (). Number , nil
200200}
201201
202202// CreateUserPullRequest creates a pull-request for a user owned repository.
203- func CreateUserPullRequest (ctx context.Context , gc gitprovider.Client , domain , branch string , spec deliveryv1alpha1.PullRequestTemplate , repository mpasv1alpha1.Repository ) error {
203+ func CreateUserPullRequest (ctx context.Context , gc gitprovider.Client , domain , branch string , spec deliveryv1alpha1.PullRequestTemplate , repository mpasv1alpha1.Repository ) ( int , error ) {
204204 // find the repository
205205 repo , err := gc .UserRepositories ().Get (ctx , gitprovider.UserRepositoryRef {
206206 UserRef : gitprovider.UserRef {
@@ -210,7 +210,7 @@ func CreateUserPullRequest(ctx context.Context, gc gitprovider.Client, domain, b
210210 RepositoryName : repository .GetName (),
211211 })
212212 if err != nil {
213- return fmt .Errorf ("failed to find user repository: %w" , err )
213+ return - 1 , fmt .Errorf ("failed to find user repository: %w" , err )
214214 }
215215
216216 var (
@@ -233,13 +233,13 @@ func CreateUserPullRequest(ctx context.Context, gc gitprovider.Client, domain, b
233233
234234 pr , err := repo .PullRequests ().Create (ctx , title , branch , base , description )
235235 if err != nil {
236- return fmt .Errorf ("failed to create pull request: %w" , err )
236+ return - 1 , fmt .Errorf ("failed to create pull request: %w" , err )
237237 }
238238
239239 logger := log .FromContext (ctx )
240240 logger .Info ("created pull request for user repository" , "user" , repository .Spec .Owner , "pull-request" , pr .Get ().Number )
241241
242- return nil
242+ return pr . Get (). Number , nil
243243}
244244
245245// Repositories groups together a common functionality of both repository types.
0 commit comments