Skip to content

Commit eb35239

Browse files
fhammerl1newsr
andauthored
Fix: convert baseUrl to serverApiUrl 'formatted' (#1289)
* fix: convert baseUrl to apiUrl * Run prettier --------- Co-authored-by: 1newsr <1newsr@users.noreply.github.com>
1 parent 83b7061 commit eb35239

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

dist/index.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,6 +1453,7 @@ const path = __importStar(__nccwpck_require__(1017));
14531453
const retryHelper = __importStar(__nccwpck_require__(2155));
14541454
const toolCache = __importStar(__nccwpck_require__(7784));
14551455
const v4_1 = __importDefault(__nccwpck_require__(824));
1456+
const url_helper_1 = __nccwpck_require__(9437);
14561457
const IS_WINDOWS = process.platform === 'win32';
14571458
function downloadRepository(authToken, owner, repo, ref, commit, repositoryPath, baseUrl) {
14581459
return __awaiter(this, void 0, void 0, function* () {
@@ -1513,7 +1514,9 @@ function getDefaultBranch(authToken, owner, repo, baseUrl) {
15131514
return yield retryHelper.execute(() => __awaiter(this, void 0, void 0, function* () {
15141515
var _a;
15151516
core.info('Retrieving the default branch name');
1516-
const octokit = github.getOctokit(authToken, { baseUrl: baseUrl });
1517+
const octokit = github.getOctokit(authToken, {
1518+
baseUrl: (0, url_helper_1.getServerApiUrl)(baseUrl)
1519+
});
15171520
let result;
15181521
try {
15191522
// Get the default branch from the repo info
@@ -1545,7 +1548,9 @@ function getDefaultBranch(authToken, owner, repo, baseUrl) {
15451548
exports.getDefaultBranch = getDefaultBranch;
15461549
function downloadArchive(authToken, owner, repo, ref, commit, baseUrl) {
15471550
return __awaiter(this, void 0, void 0, function* () {
1548-
const octokit = github.getOctokit(authToken, { baseUrl: baseUrl });
1551+
const octokit = github.getOctokit(authToken, {
1552+
baseUrl: (0, url_helper_1.getServerApiUrl)(baseUrl)
1553+
});
15491554
const download = IS_WINDOWS
15501555
? octokit.rest.repos.downloadZipballArchive
15511556
: octokit.rest.repos.downloadTarballArchive;
@@ -2026,7 +2031,7 @@ function checkCommitInfo(token, commitInfo, repositoryOwner, repositoryName, ref
20262031
if (actualHeadSha !== expectedHeadSha) {
20272032
core.debug(`Expected head sha ${expectedHeadSha}; actual head sha ${actualHeadSha}`);
20282033
const octokit = github.getOctokit(token, {
2029-
baseUrl: baseUrl,
2034+
baseUrl: (0, url_helper_1.getServerApiUrl)(baseUrl),
20302035
userAgent: `actions-checkout-tracepoint/1.0 (code=STALE_MERGE;owner=${repositoryOwner};repo=${repositoryName};pr=${fromPayload('number')};run_id=${process.env['GITHUB_RUN_ID']};expected_head_sha=${expectedHeadSha};actual_head_sha=${actualHeadSha})`
20312036
});
20322037
yield octokit.rest.repos.get({

src/github-api-helper.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import * as path from 'path'
77
import * as retryHelper from './retry-helper'
88
import * as toolCache from '@actions/tool-cache'
99
import {default as uuid} from 'uuid/v4'
10+
import {getServerApiUrl} from './url-helper'
1011

1112
const IS_WINDOWS = process.platform === 'win32'
1213

@@ -84,7 +85,9 @@ export async function getDefaultBranch(
8485
): Promise<string> {
8586
return await retryHelper.execute(async () => {
8687
core.info('Retrieving the default branch name')
87-
const octokit = github.getOctokit(authToken, {baseUrl: baseUrl})
88+
const octokit = github.getOctokit(authToken, {
89+
baseUrl: getServerApiUrl(baseUrl)
90+
})
8891
let result: string
8992
try {
9093
// Get the default branch from the repo info
@@ -125,7 +128,9 @@ async function downloadArchive(
125128
commit: string,
126129
baseUrl?: string
127130
): Promise<Buffer> {
128-
const octokit = github.getOctokit(authToken, {baseUrl: baseUrl})
131+
const octokit = github.getOctokit(authToken, {
132+
baseUrl: getServerApiUrl(baseUrl)
133+
})
129134
const download = IS_WINDOWS
130135
? octokit.rest.repos.downloadZipballArchive
131136
: octokit.rest.repos.downloadTarballArchive

src/ref-helper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {IGitCommandManager} from './git-command-manager'
22
import * as core from '@actions/core'
33
import * as github from '@actions/github'
4-
import {isGhes} from './url-helper'
4+
import {getServerApiUrl, isGhes} from './url-helper'
55

66
export const tagsRefSpec = '+refs/tags/*:refs/tags/*'
77

@@ -245,7 +245,7 @@ export async function checkCommitInfo(
245245
`Expected head sha ${expectedHeadSha}; actual head sha ${actualHeadSha}`
246246
)
247247
const octokit = github.getOctokit(token, {
248-
baseUrl: baseUrl,
248+
baseUrl: getServerApiUrl(baseUrl),
249249
userAgent: `actions-checkout-tracepoint/1.0 (code=STALE_MERGE;owner=${repositoryOwner};repo=${repositoryName};pr=${fromPayload(
250250
'number'
251251
)};run_id=${

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy