Skip to content

Commit b9a618f

Browse files
committed
Explain and group together the different status object fields
This makes the code structure a bit clearer, with no functional changes.
1 parent 9e6de75 commit b9a618f

File tree

1 file changed

+33
-21
lines changed

1 file changed

+33
-21
lines changed

lib/get-user-status.js

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,20 @@ module.exports = async (submitterGitHubID, repoName) => {
5656
return statusNothing(submitterGitHubID, repoName);
5757
};
5858

59+
// In what follows, for convenience (including of testing) we have a single object that mixes
60+
// together fields used by GitHub (most of them) with fields used by agreement-status.hbs
61+
// (isNothing and longDescription). So, we only need to HTML escape the fields we display; GitHub
62+
// will do its own escaping for description and target_url.
63+
5964
function statusIndividual(submitterGitHubID, repoName) {
6065
return {
6166
state: "success",
62-
isNothing: false,
6367
description: `@${submitterGitHubID} has signed up to participate as an individual`,
64-
longDescription: html`@${submitterGitHubID} has signed up to participate as an individual. All is well; contribute at will!`,
6568
target_url: `${statusURLBase}?user=${submitterGitHubID}&repo=${repoName}`,
66-
context: "Participation"
69+
context: "Participation",
70+
71+
isNothing: false,
72+
longDescription: html`@${submitterGitHubID} has signed up to participate as an individual. All is well; contribute at will!`
6773
};
6874
}
6975

@@ -73,22 +79,24 @@ function statusIndividualNoWorkstreams(submitterGitHubID, repoName) {
7379

7480
return {
7581
state: "pending",
76-
isNothing: false,
7782
description: `@${submitterGitHubID} participates as an individual, but not in this workstream`,
78-
longDescription: html`@${submitterGitHubID} has signed up to participate as an individual, but has not chosen to participate in the ${workstreamName} workstream. To amend your agreement, submit a pull request to <a href="https://github.com/${repo}">${repo}</a>.`,
7983
target_url: `${statusURLBase}?user=${submitterGitHubID}&repo=${repoName}`,
80-
context: "Participation"
84+
context: "Participation",
85+
86+
isNothing: false,
87+
longDescription: html`@${submitterGitHubID} has signed up to participate as an individual, but has not chosen to participate in the ${workstreamName} workstream. To amend your agreement, submit a pull request to <a href="https://github.com/${repo}">${repo}</a>.`
8188
};
8289
}
8390

8491
function statusIndividualUnverified(submitterGitHubID, repoName) {
8592
return {
8693
state: "pending",
87-
isNothing: false,
8894
description: `@${submitterGitHubID} is not yet verified`,
89-
longDescription: html`@${submitterGitHubID} has signed up to participate as an individual, but has not yet been verified. Hold tight while we sort this out on our end!`,
9095
target_url: `${statusURLBase}?user=${submitterGitHubID}&repo=${repoName}`,
91-
context: "Participation"
96+
context: "Participation",
97+
98+
isNothing: false,
99+
longDescription: html`@${submitterGitHubID} has signed up to participate as an individual, but has not yet been verified. Hold tight while we sort this out on our end!`
92100
};
93101
}
94102

@@ -97,11 +105,12 @@ function statusEntity(submitterGitHubID, repoName, entity) {
97105

98106
return {
99107
state: "success",
100-
isNothing: false,
101108
description: `${submitterGitHubID} participates on behalf of ${entity.info.name}`,
102-
longDescription: html`@${submitterGitHubID} is part of the ${entity.info.gitHubOrganization} GitHub organization, associated with ${entity.info.name}, which has signed the agreement and participates in the ${workstreamName} workstream. All is well; contribute at will!`,
103109
target_url: `${statusURLBase}?user=${submitterGitHubID}&repo=${repoName}`,
104-
context: "Participation"
110+
context: "Participation",
111+
112+
isNothing: false,
113+
longDescription: html`@${submitterGitHubID} is part of the ${entity.info.gitHubOrganization} GitHub organization, associated with ${entity.info.name}, which has signed the agreement and participates in the ${workstreamName} workstream. All is well; contribute at will!`
105114
};
106115
}
107116

@@ -110,11 +119,12 @@ function statusEntitiesUnverified(submitterGitHubID, repoName, entities) {
110119

111120
return {
112121
state: "pending",
113-
isNothing: false,
114122
description: `@${submitterGitHubID} participates on behalf of an unverified entity`,
115-
longDescription: html`@${submitterGitHubID} is part of the ${orgs} GitHub ${word}, but ${pronoun} ${haveVerb} not yet been verified. Hold tight while we sort this out on our end!`,
116123
target_url: `${statusURLBase}?user=${submitterGitHubID}&repo=${repoName}`,
117-
context: "Participation"
124+
context: "Participation",
125+
126+
isNothing: false,
127+
longDescription: html`@${submitterGitHubID} is part of the ${orgs} GitHub ${word}, but ${pronoun} ${haveVerb} not yet been verified. Hold tight while we sort this out on our end!`
118128
};
119129
}
120130

@@ -124,22 +134,24 @@ function statusEntityNoWorkstreams(submitterGitHubID, repoName, entities) {
124134

125135
return {
126136
state: "pending",
127-
isNothing: false,
128137
description: `@${submitterGitHubID} participates on behalf of a non-workstream entity`,
129-
longDescription: html`@${submitterGitHubID} is part of the ${orgs} GitHub ${word}, but ${pronoun} ${doVerb} not participate in the ${workstreamName} workstream. Please have the contact for ${pronoun2} ${word} update their participation agreement.`,
130138
target_url: `${statusURLBase}?user=${submitterGitHubID}&repo=${repoName}`,
131-
context: "Participation"
139+
context: "Participation",
140+
141+
isNothing: false,
142+
longDescription: html`@${submitterGitHubID} is part of the ${orgs} GitHub ${word}, but ${pronoun} ${doVerb} not participate in the ${workstreamName} workstream. Please have the contact for ${pronoun2} ${word} update their participation agreement.`
132143
};
133144
}
134145

135146
function statusNothing(submitterGitHubID, repoName) {
136147
return {
137148
state: "pending",
138-
isNothing: true,
139149
description: `@${submitterGitHubID} has not signed up to participate`,
140-
longDescription: html`@${submitterGitHubID} does not appear to have signed the agreement, or be associated with an entity that has done so. Please sign it, or forward it to an authorized representative!`,
141150
target_url: `${statusURLBase}?user=${submitterGitHubID}&repo=${repoName}`,
142-
context: "Participation"
151+
context: "Participation",
152+
153+
isNothing: true,
154+
longDescription: html`@${submitterGitHubID} does not appear to have signed the agreement, or be associated with an entity that has done so. Please sign it, or forward it to an authorized representative!`
143155
};
144156
}
145157

0 commit comments

Comments
 (0)