MCPcopy Index your code
hub / github.com/1Password/for-open-source / Parse

Method Parse

script/application.go:56–111  ·  view source on GitHub ↗
(issue *github.Issue)

Source from the content-addressed store, hash-verified

54}
55
56func (a *Application) Parse(issue *github.Issue) {
57 a.validator = Validator{}
58
59 if strings.Contains(*issue.Title, "[project name]") {
60 a.validator.AddError("Application title", *issue.Title, "is missing project name")
61 }
62
63 a.sections = a.extractSections(*issue.Body)
64
65 if isTesting() {
66 data, err := json.MarshalIndent(a.sections, "", "\t")
67 if err != nil {
68 sentry.CaptureException(err)
69 log.Fatalf("Could not marshal Sections input data: %s", err.Error())
70 }
71
72 debugMessage("Parsed input data:", string(data))
73 }
74
75 a.CreatedAt = issue.CreatedAt.Time
76 a.IssueNumber = *issue.Number
77 a.Account = a.stringSection("Account URL", true, ParseAccountURL)
78 a.boolSection("Non-commercial confirmation", true, ParseCheckbox, IsChecked)
79
80 a.Project.IsTeam = a.boolSection("Team application", false, ParseCheckbox)
81 a.Project.IsEvent = a.boolSection("Event application", false, ParseCheckbox)
82
83 isProject := !a.Project.IsTeam && !a.Project.IsEvent
84
85 a.Project.Name = a.stringSection("Project name", true, ParsePlainString)
86 a.Project.Description = a.stringSection("Short description", true, ParsePlainString)
87 a.Project.Contributors = a.intSection("Number of team members/core contributors", true, ParsePlainString)
88 a.Project.HomeURL = a.stringSection("Homepage URL", true, IsURL)
89 a.Project.RepoURL = a.stringSection("Repository URL", false, IsURL)
90 a.Project.LicenseType = a.stringSection("License type", isProject, ParsePlainString)
91 a.Project.LicenseURL = a.stringSection("License URL", isProject, IsURL)
92 a.boolSection("Age confirmation", isProject, ParseCheckbox, When(isProject, IsChecked))
93
94 a.Applicant.Name = a.stringSection("Name", true, ParsePlainString)
95 a.Applicant.Email = a.stringSection("Email", true, IsEmail)
96 a.Applicant.Role = a.stringSection("Project role", true)
97 a.Applicant.ID = *issue.User.ID
98
99 a.stringSection("Profile or website", false, IsURL)
100 a.stringSection("Additional comments", false)
101
102 a.CanContact = a.boolSection("Can we contact you?", false, ParseCheckbox)
103
104 if isTesting() {
105 debugMessage("Application data:", string(a.GetData()))
106 }
107
108 for _, err := range a.validator.Errors {
109 a.Problems = append(a.Problems, fmt.Errorf(err.Error()))
110 }
111}
112
113func (a *Application) IsValid() bool {

Callers 4

TestApplication_ParseFunction · 0.95
ParseAccountURLFunction · 0.80
ApproveMethod · 0.80
ReviewMethod · 0.80

Calls 10

extractSectionsMethod · 0.95
stringSectionMethod · 0.95
boolSectionMethod · 0.95
intSectionMethod · 0.95
GetDataMethod · 0.95
isTestingFunction · 0.85
debugMessageFunction · 0.85
WhenFunction · 0.85
AddErrorMethod · 0.80
ErrorMethod · 0.80

Tested by 1

TestApplication_ParseFunction · 0.76