This is an automated email from the ASF dual-hosted git repository.
warren pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/main by this push:
new 7b13e8949 fix: check nil for HeadRef and BaseRef (#4598)
7b13e8949 is described below
commit 7b13e8949db48d11df3b1b33d5b20db585a624c6
Author: Likyh <[email protected]>
AuthorDate: Tue Mar 7 17:17:08 2023 +0800
fix: check nil for HeadRef and BaseRef (#4598)
---
backend/plugins/bitbucket/tasks/pr_extractor.go | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/backend/plugins/bitbucket/tasks/pr_extractor.go
b/backend/plugins/bitbucket/tasks/pr_extractor.go
index 8a8ab6c21..22020672a 100644
--- a/backend/plugins/bitbucket/tasks/pr_extractor.go
+++ b/backend/plugins/bitbucket/tasks/pr_extractor.go
@@ -129,8 +129,6 @@ func convertBitbucketPullRequest(pull
*BitbucketApiPullRequest, connId uint64, r
BitbucketId: pull.BitbucketId,
Number: pull.BitbucketId,
RepoId: repoId,
- BaseRepoId: pull.BaseRef.Repo.FullName,
- HeadRepoId: pull.HeadRef.Repo.FullName,
State: pull.State,
Title: pull.Title,
Description: pull.Description,
@@ -139,10 +137,20 @@ func convertBitbucketPullRequest(pull
*BitbucketApiPullRequest, connId uint64, r
CommentCount: pull.CommentCount,
BitbucketCreatedAt: pull.BitbucketCreatedAt,
BitbucketUpdatedAt: pull.BitbucketUpdatedAt,
- BaseRef: pull.BaseRef.Branch.Name,
- BaseCommitSha: pull.BaseRef.Commit.Hash,
- HeadRef: pull.HeadRef.Branch.Name,
- HeadCommitSha: pull.HeadRef.Commit.Hash,
+ }
+ if pull.BaseRef != nil {
+ if pull.BaseRef.Repo != nil {
+ bitbucketPull.BaseRepoId = pull.BaseRef.Repo.FullName
+ }
+ bitbucketPull.BaseRef = pull.BaseRef.Branch.Name
+ bitbucketPull.BaseCommitSha = pull.BaseRef.Commit.Hash
+ }
+ if pull.HeadRef != nil {
+ if pull.HeadRef.Repo != nil {
+ bitbucketPull.HeadRepoId = pull.HeadRef.Repo.FullName
+ }
+ bitbucketPull.HeadRef = pull.HeadRef.Branch.Name
+ bitbucketPull.HeadCommitSha = pull.HeadRef.Commit.Hash
}
return bitbucketPull, nil
}