mirror of
				https://code.forgejo.org/actions/checkout.git
				synced 2025-10-31 04:52:29 +00:00 
			
		
		
		
	restore passing baseUrl where appropriate
				
					
				
			This commit is contained in:
		
							parent
							
								
									df4b58c789
								
							
						
					
					
						commit
						2f42443dda
					
				
					 3 changed files with 39 additions and 15 deletions
				
			
		
							
								
								
									
										46
									
								
								dist/index.js
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										46
									
								
								dist/index.js
									
										
									
									
										vendored
									
									
								
							|  | @ -1617,7 +1617,7 @@ function getDefaultBranch(authToken, owner, repo, baseUrl) { | |||
|         return yield retryHelper.execute(() => __awaiter(this, void 0, void 0, function* () { | ||||
|             core.info('Retrieving the default branch name'); | ||||
|             const octokit = github.getOctokit(authToken, { | ||||
|                 baseUrl: (0, url_helper_1.getServerApiUrl)() | ||||
|                 baseUrl: (0, url_helper_1.getServerApiUrl)(baseUrl) | ||||
|             }); | ||||
|             let result; | ||||
|             try { | ||||
|  | @ -1650,7 +1650,7 @@ function getDefaultBranch(authToken, owner, repo, baseUrl) { | |||
| function downloadArchive(authToken, owner, repo, ref, commit, baseUrl) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         const octokit = github.getOctokit(authToken, { | ||||
|             baseUrl: (0, url_helper_1.getServerApiUrl)() | ||||
|             baseUrl: (0, url_helper_1.getServerApiUrl)(baseUrl) | ||||
|         }); | ||||
|         const download = IS_WINDOWS | ||||
|             ? octokit.rest.repos.downloadZipballArchive | ||||
|  | @ -2128,7 +2128,7 @@ function checkCommitInfo(token, commitInfo, repositoryOwner, repositoryName, ref | |||
|         var _a; | ||||
|         try { | ||||
|             // GHES?
 | ||||
|             if ((0, url_helper_1.isGhes)()) { | ||||
|             if ((0, url_helper_1.isGhes)(baseUrl)) { | ||||
|                 return; | ||||
|             } | ||||
|             // Auth token?
 | ||||
|  | @ -2174,7 +2174,7 @@ function checkCommitInfo(token, commitInfo, repositoryOwner, repositoryName, ref | |||
|             if (actualHeadSha !== expectedHeadSha) { | ||||
|                 core.debug(`Expected head sha ${expectedHeadSha}; actual head sha ${actualHeadSha}`); | ||||
|                 const octokit = github.getOctokit(token, { | ||||
|                     baseUrl: (0, url_helper_1.getServerApiUrl)(), | ||||
|                     baseUrl: (0, url_helper_1.getServerApiUrl)(baseUrl), | ||||
|                     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})` | ||||
|                 }); | ||||
|                 yield octokit.rest.repos.get({ | ||||
|  | @ -2454,22 +2454,46 @@ function getFetchUrl(settings) { | |||
|     return `${serviceUrl.origin}/${encodedOwner}/${encodedName}`; | ||||
| } | ||||
| function getServerUrl(url) { | ||||
|     let urlValue = url && url.trim().length > 0 | ||||
|         ? url | ||||
|         : process.env['GITHUB_SERVER_URL'] || 'https://github.com'; | ||||
|     return new url_1.URL(urlValue); | ||||
|     let resolvedUrl = process.env['GITHUB_SERVER_URL'] || 'https://github.com'; | ||||
|     if (hasContent(url, false)) { | ||||
|         resolvedUrl = url; | ||||
|     } | ||||
|     return new url_1.URL(resolvedUrl); | ||||
| } | ||||
| function getServerApiUrl() { | ||||
| function getServerApiUrl(url) { | ||||
|     if (hasContent(url, false)) { | ||||
|         let serverUrl = getServerUrl(url); | ||||
|         if (isGhes(url)) { | ||||
|             serverUrl.pathname = "api/v3"; | ||||
|         } | ||||
|         else { | ||||
|             serverUrl.hostname = "api." + serverUrl.hostname; | ||||
|         } | ||||
|         return pruneSuffix(serverUrl.toString(), '/'); | ||||
|     } | ||||
|     return process.env['GITHUB_API_URL'] || 'https://api.github.com'; | ||||
| } | ||||
| function isGhes() { | ||||
|     const ghUrl = new url_1.URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); | ||||
| function isGhes(url) { | ||||
|     const ghUrl = new url_1.URL(url || process.env['GITHUB_SERVER_URL'] || 'https://github.com'); | ||||
|     const hostname = ghUrl.hostname.trimEnd().toUpperCase(); | ||||
|     const isGitHubHost = hostname === 'GITHUB.COM'; | ||||
|     const isGheHost = hostname.endsWith('.GHE.COM'); | ||||
|     const isLocalHost = hostname.endsWith('.LOCALHOST'); | ||||
|     return !isGitHubHost && !isGheHost && !isLocalHost; | ||||
| } | ||||
| function pruneSuffix(text, suffix) { | ||||
|     if (hasContent(suffix, true) && (text === null || text === void 0 ? void 0 : text.endsWith(suffix))) { | ||||
|         return text.substring(0, text.length - suffix.length); | ||||
|     } | ||||
|     return text; | ||||
| } | ||||
| function hasContent(text, allowPureWhitespace) { | ||||
|     let refinedText = text !== null && text !== void 0 ? text : ""; | ||||
|     if (!allowPureWhitespace) { | ||||
|         refinedText = refinedText.trim(); | ||||
|     } | ||||
|     return refinedText.length > 0; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| /***/ }), | ||||
|  |  | |||
|  | @ -88,7 +88,7 @@ export async function getDefaultBranch( | |||
|   return await retryHelper.execute(async () => { | ||||
|     core.info('Retrieving the default branch name') | ||||
|     const octokit = github.getOctokit(authToken, { | ||||
|       baseUrl: getServerApiUrl() | ||||
|       baseUrl: getServerApiUrl(baseUrl) | ||||
|     }) | ||||
|     let result: string | ||||
|     try { | ||||
|  | @ -131,7 +131,7 @@ async function downloadArchive( | |||
|   baseUrl?: string | ||||
| ): Promise<Buffer> { | ||||
|   const octokit = github.getOctokit(authToken, { | ||||
|     baseUrl: getServerApiUrl() | ||||
|     baseUrl: getServerApiUrl(baseUrl) | ||||
|   }) | ||||
|   const download = IS_WINDOWS | ||||
|     ? octokit.rest.repos.downloadZipballArchive | ||||
|  |  | |||
|  | @ -192,7 +192,7 @@ export async function checkCommitInfo( | |||
| ): Promise<void> { | ||||
|   try { | ||||
|     // GHES?
 | ||||
|     if (isGhes()) { | ||||
|     if (isGhes(baseUrl)) { | ||||
|       return | ||||
|     } | ||||
| 
 | ||||
|  | @ -249,7 +249,7 @@ export async function checkCommitInfo( | |||
|         `Expected head sha ${expectedHeadSha}; actual head sha ${actualHeadSha}` | ||||
|       ) | ||||
|       const octokit = github.getOctokit(token, { | ||||
|         baseUrl: getServerApiUrl(), | ||||
|         baseUrl: getServerApiUrl(baseUrl), | ||||
|         userAgent: `actions-checkout-tracepoint/1.0 (code=STALE_MERGE;owner=${repositoryOwner};repo=${repositoryName};pr=${fromPayload( | ||||
|           'number' | ||||
|         )};run_id=${ | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue