Skip to content

Commit

Permalink
Fix golang-ci notes (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
omerzi authored Jul 30, 2023
1 parent a7e3800 commit 2b3de63
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
8 changes: 4 additions & 4 deletions vcsclient/azurerepos.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ func (client *AzureReposClient) getOpenPullRequests(ctx context.Context, owner,
}
var pullRequestsInfo []PullRequestInfo
for _, pullRequest := range *pullRequests {
pullRequestDetails := parsePullRequestDetails(client, pullRequest, owner, repository)
pullRequestDetails := parsePullRequestDetails(client, pullRequest, owner, repository, withBody)
pullRequestsInfo = append(pullRequestsInfo, pullRequestDetails)
}
return pullRequestsInfo, nil
Expand All @@ -320,7 +320,7 @@ func (client *AzureReposClient) GetPullRequestByID(ctx context.Context, owner, r
if err != nil {
return
}
pullRequestInfo = parsePullRequestDetails(client, *pullRequest, owner, repository)
pullRequestInfo = parsePullRequestDetails(client, *pullRequest, owner, repository, false)
return
}

Expand Down Expand Up @@ -575,14 +575,14 @@ func (client *AzureReposClient) GetModifiedFiles(ctx context.Context, _, reposit
return fileNamesList, nil
}

func parsePullRequestDetails(client *AzureReposClient, pullRequest git.GitPullRequest, owner, repository string) PullRequestInfo {
func parsePullRequestDetails(client *AzureReposClient, pullRequest git.GitPullRequest, owner, repository string, withBody bool) PullRequestInfo {
// Trim the branches prefix and get the actual branches name
shortSourceName := (*pullRequest.SourceRefName)[strings.LastIndex(*pullRequest.SourceRefName, "/")+1:]
shortTargetName := (*pullRequest.TargetRefName)[strings.LastIndex(*pullRequest.TargetRefName, "/")+1:]

var prBody string
bodyPtr := pullRequest.Description
if bodyPtr != nil {
if bodyPtr != nil && withBody {
prBody = *bodyPtr
}

Expand Down
9 changes: 4 additions & 5 deletions vcsclient/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -620,12 +620,11 @@ func (client *GitHubClient) UploadCodeScanning(ctx context.Context, owner, repos
if sarifID != nil && *sarifID.ID != "" {
return *sarifID.ID, err
}
aerr, ok := err.(*github.AcceptedError)
var result map[string]string
if ok {
err = json.Unmarshal(aerr.Raw, &result)
if err != nil {
return "", nil
var ghAcceptedError *github.AcceptedError
if errors.As(err, &ghAcceptedError) {
if err = json.Unmarshal(ghAcceptedError.Raw, &result); err != nil {
return "", err
}
return result["id"], nil
}
Expand Down

0 comments on commit 2b3de63

Please sign in to comment.