MCPcopy Index your code
hub / github.com/bytebase/bytebase / getGitHubVCSUser

Function getGitHubVCSUser

action/command/vcs_user.go:36–74  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

34}
35
36func getGitHubVCSUser() *v1pb.VCSUser {
37 eventName := os.Getenv("GITHUB_EVENT_NAME")
38 if eventName != "pull_request" && eventName != "pull_request_target" {
39 return nil
40 }
41 eventPath := os.Getenv("GITHUB_EVENT_PATH")
42 if eventPath == "" {
43 return nil
44 }
45 data, err := os.ReadFile(eventPath)
46 if err != nil {
47 return nil
48 }
49
50 var event struct {
51 PullRequest struct {
52 User struct {
53 ID int64 `json:"id"`
54 Login string `json:"login"`
55 Name string `json:"name"`
56 Type string `json:"type"`
57 } `json:"user"`
58 } `json:"pull_request"`
59 }
60 if err := json.Unmarshal(data, &event); err != nil {
61 return nil
62 }
63
64 user := event.PullRequest.User
65 if user.ID == 0 || isBotUser(user.Type, user.Login) {
66 return nil
67 }
68 return &v1pb.VCSUser{
69 VcsType: v1pb.VCSType_GITHUB,
70 UserId: strconv.FormatInt(user.ID, 10),
71 UserName: user.Login,
72 DisplayName: user.Name,
73 }
74}
75
76func getGitLabVCSUser() *v1pb.VCSUser {
77 projectID := os.Getenv("CI_MERGE_REQUEST_PROJECT_ID")

Callers 1

getVCSUserFunction · 0.85

Calls 2

isBotUserFunction · 0.85
UnmarshalMethod · 0.80

Tested by

no test coverage detected