mirror of
https://code.forgejo.org/actions/checkout.git
synced 2025-04-22 01:22:02 +03:00
.
This commit is contained in:
parent
2285ac189f
commit
adfd38e27a
3 changed files with 98 additions and 72 deletions
|
@ -13,7 +13,7 @@ import {IGitCommandManager} from './git-command-manager'
|
|||
|
||||
const serverUrl = 'https://github.com/'
|
||||
const authConfigKey = `http.${serverUrl}.extraheader`
|
||||
const proxyConfigKey = `http.${serverUrl}.proxy`
|
||||
// const proxyConfigKey = `http.${serverUrl}.proxy`
|
||||
|
||||
export interface ISourceSettings {
|
||||
repositoryPath: string
|
||||
|
@ -96,12 +96,12 @@ export async function getSource(settings: ISourceSettings): Promise<void> {
|
|||
}
|
||||
|
||||
// Remove possible previous proxy and extraheader
|
||||
await removeGitConfig(git, proxyConfigKey)
|
||||
// await removeGitConfig(git, proxyConfigKey)
|
||||
await removeGitConfig(git, authConfigKey)
|
||||
|
||||
try {
|
||||
// Config proxy and extraheader
|
||||
await configureProxy(git)
|
||||
// await configureProxy(git)
|
||||
await configureAuthToken(git, settings.authToken)
|
||||
|
||||
// LFS install
|
||||
|
@ -134,7 +134,7 @@ export async function getSource(settings: ISourceSettings): Promise<void> {
|
|||
await git.log1()
|
||||
} finally {
|
||||
if (!settings.persistCredentials) {
|
||||
await removeGitConfig(git, proxyConfigKey)
|
||||
// await removeGitConfig(git, proxyConfigKey)
|
||||
await removeGitConfig(git, authConfigKey)
|
||||
}
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ export async function cleanup(repositoryPath: string): Promise<void> {
|
|||
return
|
||||
}
|
||||
|
||||
await removeGitConfig(git, proxyConfigKey)
|
||||
// await removeGitConfig(git, proxyConfigKey)
|
||||
await removeGitConfig(git, authConfigKey)
|
||||
}
|
||||
|
||||
|
@ -268,33 +268,33 @@ async function prepareExistingDirectory(
|
|||
}
|
||||
}
|
||||
|
||||
async function configureProxy(git: IGitCommandManager): Promise<void> {
|
||||
const proxyUrl = httpClient.getProxyUrl(serverUrl)
|
||||
const parsedUrl = url.parse(proxyUrl)
|
||||
const placeholder = parsedUrl.auth
|
||||
? proxyUrl.replace(parsedUrl.auth, '***')
|
||||
: ''
|
||||
// async function configureProxy(git: IGitCommandManager): Promise<void> {
|
||||
// const proxyUrl = httpClient.getProxyUrl(serverUrl)
|
||||
// const parsedUrl = url.parse(proxyUrl)
|
||||
// const placeholder = parsedUrl.auth
|
||||
// ? proxyUrl.replace(parsedUrl.auth, '***')
|
||||
// : ''
|
||||
|
||||
// Configure a placeholder value. This approach avoids the credential being captured
|
||||
// by process creation audit events, which are commonly logged. For more information,
|
||||
// refer to https://docs.microsoft.com/en-us/windows-server/identity/ad-ds/manage/component-updates/command-line-process-auditing
|
||||
await git.config(proxyConfigKey, placeholder || proxyUrl)
|
||||
// // Configure a placeholder value. This approach avoids the credential being captured
|
||||
// // by process creation audit events, which are commonly logged. For more information,
|
||||
// // refer to https://docs.microsoft.com/en-us/windows-server/identity/ad-ds/manage/component-updates/command-line-process-auditing
|
||||
// await git.config(proxyConfigKey, placeholder || proxyUrl)
|
||||
|
||||
if (placeholder) {
|
||||
// Replace the value in the config file
|
||||
const configPath = path.join(git.getWorkingDirectory(), '.git', 'config')
|
||||
let content = (await fs.promises.readFile(configPath)).toString()
|
||||
const placeholderIndex = content.indexOf(placeholder)
|
||||
if (
|
||||
placeholderIndex < 0 ||
|
||||
placeholderIndex != content.lastIndexOf(placeholder)
|
||||
) {
|
||||
throw new Error('Unable to replace auth placeholder in .git/config')
|
||||
}
|
||||
content = content.replace(placeholder, proxyUrl)
|
||||
await fs.promises.writeFile(configPath, content)
|
||||
}
|
||||
}
|
||||
// if (placeholder) {
|
||||
// // Replace the value in the config file
|
||||
// const configPath = path.join(git.getWorkingDirectory(), '.git', 'config')
|
||||
// let content = (await fs.promises.readFile(configPath)).toString()
|
||||
// const placeholderIndex = content.indexOf(placeholder)
|
||||
// if (
|
||||
// placeholderIndex < 0 ||
|
||||
// placeholderIndex != content.lastIndexOf(placeholder)
|
||||
// ) {
|
||||
// throw new Error('Unable to replace auth placeholder in .git/config')
|
||||
// }
|
||||
// content = content.replace(placeholder, proxyUrl)
|
||||
// await fs.promises.writeFile(configPath, content)
|
||||
// }
|
||||
// }
|
||||
|
||||
async function configureAuthToken(
|
||||
git: IGitCommandManager,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue