Skip to content

Commit c0078b2

Browse files
CopilotTingluoHuang
andcommitted
Simplify user-agent logic and update integration test
Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com>
1 parent c36bdc0 commit c0078b2

File tree

3 files changed

+3
-10
lines changed

3 files changed

+3
-10
lines changed

.github/workflows/integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ jobs:
167167
exit 1
168168
fi
169169
echo "- Validating user-agent set to an empty string"
170-
expected="octokit-core.js/"
170+
expected="actions/github-script octokit-core.js/"
171171
if [[ "${{steps.user-agent-empty.outputs.result}}" != "$expected"* ]]; then
172172
echo $'::error::\u274C' "Expected user-agent to start with '$expected', got ${{steps.user-agent-empty.outputs.result}}"
173173
exit 1

dist/index.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36267,7 +36267,7 @@ async function main() {
3626736267
const retries = parseInt(core.getInput('retries'));
3626836268
const exemptStatusCodes = parseNumberArray(core.getInput('retry-exempt-status-codes'));
3626936269
const [retryOpts, requestOpts] = getRetryOptions(retries, exemptStatusCodes, utils.defaults);
36270-
const baseUserAgent = userAgent === '' ? '' : userAgent || 'actions/github-script';
36270+
const baseUserAgent = userAgent || 'actions/github-script';
3627136271
const finalUserAgent = getUserAgentWithOrchestrationId(baseUserAgent);
3627236272
const opts = {
3627336273
log: debug ? console : undefined,
@@ -36327,9 +36327,6 @@ function getUserAgentWithOrchestrationId(userAgent) {
3632736327
}
3632836328
// Sanitize orchestration ID - replace invalid characters with underscore
3632936329
const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '_');
36330-
if (!sanitized) {
36331-
return userAgent;
36332-
}
3633336330
return `${userAgent} orchestration-id/${sanitized}`;
3633436331
}
3633536332

src/main.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ async function main(): Promise<void> {
3939
defaultGitHubOptions
4040
)
4141

42-
const baseUserAgent =
43-
userAgent === '' ? '' : userAgent || 'actions/github-script'
42+
const baseUserAgent = userAgent || 'actions/github-script'
4443
const finalUserAgent = getUserAgentWithOrchestrationId(baseUserAgent)
4544

4645
const opts: Options = {
@@ -114,9 +113,6 @@ function getUserAgentWithOrchestrationId(userAgent: string): string {
114113

115114
// Sanitize orchestration ID - replace invalid characters with underscore
116115
const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '_')
117-
if (!sanitized) {
118-
return userAgent
119-
}
120116

121117
return `${userAgent} orchestration-id/${sanitized}`
122118
}

0 commit comments

Comments
 (0)