Skip to content

Commit

Permalink
deps: @npmcli/git@5.0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
wraithgar committed Jul 9, 2024
1 parent 3101a40 commit 1c8d41d
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 11 deletions.
4 changes: 3 additions & 1 deletion DEPENDENCIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ graph LR;
npmcli-docs-->npmcli-template-oss["@npmcli/template-oss"];
npmcli-docs-->semver;
npmcli-fs-->semver;
npmcli-git-->ini;
npmcli-git-->npm-pick-manifest;
npmcli-git-->npmcli-promise-spawn["@npmcli/promise-spawn"];
npmcli-git-->proc-log;
Expand Down Expand Up @@ -643,6 +644,7 @@ graph LR;
npmcli-docs-->unified;
npmcli-docs-->yaml;
npmcli-fs-->semver;
npmcli-git-->ini;
npmcli-git-->lru-cache;
npmcli-git-->npm-pick-manifest;
npmcli-git-->npmcli-promise-spawn["@npmcli/promise-spawn"];
Expand Down Expand Up @@ -801,4 +803,4 @@ packages higher up the chain.
- @npmcli/git, make-fetch-happen
- @npmcli/installed-package-contents, @npmcli/map-workspaces, cacache, npm-pick-manifest, promzard
- @npmcli/docs, @npmcli/fs, npm-bundled, read-package-json-fast, unique-filename, npm-install-checks, npm-package-arg, normalize-package-data, npm-packlist, bin-links, nopt, parse-conflict-json, @npmcli/mock-globals, read
- @npmcli/eslint-config, @npmcli/template-oss, ignore-walk, semver, npm-normalize-package-bin, @npmcli/name-from-folder, json-parse-even-better-errors, fs-minipass, ssri, unique-slug, @npmcli/promise-spawn, hosted-git-info, proc-log, validate-npm-package-name, @npmcli/node-gyp, @npmcli/redact, @npmcli/agent, minipass-fetch, @npmcli/query, cmd-shim, read-cmd-shim, write-file-atomic, abbrev, proggy, minify-registry-metadata, ini, mute-stream, npm-audit-report, npm-user-validate
- @npmcli/eslint-config, @npmcli/template-oss, ignore-walk, semver, npm-normalize-package-bin, @npmcli/name-from-folder, json-parse-even-better-errors, fs-minipass, ssri, unique-slug, @npmcli/promise-spawn, ini, hosted-git-info, proc-log, validate-npm-package-name, @npmcli/node-gyp, @npmcli/redact, @npmcli/agent, minipass-fetch, @npmcli/query, cmd-shim, read-cmd-shim, write-file-atomic, abbrev, proggy, minify-registry-metadata, mute-stream, npm-audit-report, npm-user-validate
53 changes: 49 additions & 4 deletions node_modules/@npmcli/git/lib/opts.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,57 @@
const fs = require('node:fs')
const os = require('node:os')
const path = require('node:path')
const ini = require('ini')

const gitConfigPath = path.join(os.homedir(), '.gitconfig')

let cachedConfig = null

// Function to load and cache the git config
const loadGitConfig = () => {
if (cachedConfig === null) {
try {
cachedConfig = {}
if (fs.existsSync(gitConfigPath)) {
const configContent = fs.readFileSync(gitConfigPath, 'utf-8')
cachedConfig = ini.parse(configContent)
}
} catch (error) {
cachedConfig = {}
}
}
return cachedConfig
}

const checkGitConfigs = () => {
const config = loadGitConfig()
return {
sshCommandSetInConfig: config?.core?.sshCommand !== undefined,
askPassSetInConfig: config?.core?.askpass !== undefined,
}
}

const sshCommandSetInEnv = process.env.GIT_SSH_COMMAND !== undefined
const askPassSetInEnv = process.env.GIT_ASKPASS !== undefined
const { sshCommandSetInConfig, askPassSetInConfig } = checkGitConfigs()

// Values we want to set if they're not already defined by the end user
// This defaults to accepting new ssh host key fingerprints
const gitEnv = {
GIT_ASKPASS: 'echo',
GIT_SSH_COMMAND: 'ssh -oStrictHostKeyChecking=accept-new',
const finalGitEnv = {
...(askPassSetInEnv || askPassSetInConfig ? {} : {
GIT_ASKPASS: 'echo',
}),
...(sshCommandSetInEnv || sshCommandSetInConfig ? {} : {
GIT_SSH_COMMAND: 'ssh -oStrictHostKeyChecking=accept-new',
}),
}

module.exports = (opts = {}) => ({
stdioString: true,
...opts,
shell: false,
env: opts.env || { ...gitEnv, ...process.env },
env: opts.env || { ...finalGitEnv, ...process.env },
})

// Export the loadGitConfig function for testing
module.exports.loadGitConfig = loadGitConfig
3 changes: 2 additions & 1 deletion node_modules/@npmcli/git/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@npmcli/git",
"version": "5.0.7",
"version": "5.0.8",
"main": "lib/index.js",
"files": [
"bin/",
Expand Down Expand Up @@ -38,6 +38,7 @@
},
"dependencies": {
"@npmcli/promise-spawn": "^7.0.0",
"ini": "^4.1.3",
"lru-cache": "^10.0.1",
"npm-pick-manifest": "^9.0.0",
"proc-log": "^4.0.0",
Expand Down
9 changes: 5 additions & 4 deletions package-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
"devDependencies": {
"@npmcli/docs": "^1.0.0",
"@npmcli/eslint-config": "^4.0.2",
"@npmcli/git": "^5.0.7",
"@npmcli/git": "^5.0.8",
"@npmcli/mock-globals": "^1.0.0",
"@npmcli/mock-registry": "^1.0.0",
"@npmcli/template-oss": "4.22.0",
Expand Down Expand Up @@ -1626,13 +1626,14 @@
}
},
"node_modules/@npmcli/git": {
"version": "5.0.7",
"resolved": "https://registry.npmjs.org/@npmcli/git/-/git-5.0.7.tgz",
"integrity": "sha512-WaOVvto604d5IpdCRV2KjQu8PzkfE96d50CQGKgywXh2GxXmDeUO5EWcBC4V57uFyrNqx83+MewuJh3WTR3xPA==",
"version": "5.0.8",
"resolved": "https://registry.npmjs.org/@npmcli/git/-/git-5.0.8.tgz",
"integrity": "sha512-liASfw5cqhjNW9UFd+ruwwdEf/lbOAQjLL2XY2dFW/bkJheXDYZgOyul/4gVvEV4BWkTXjYGmDqMw9uegdbJNQ==",
"inBundle": true,
"license": "ISC",
"dependencies": {
"@npmcli/promise-spawn": "^7.0.0",
"ini": "^4.1.3",
"lru-cache": "^10.0.1",
"npm-pick-manifest": "^9.0.0",
"proc-log": "^4.0.0",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@
"devDependencies": {
"@npmcli/docs": "^1.0.0",
"@npmcli/eslint-config": "^4.0.2",
"@npmcli/git": "^5.0.7",
"@npmcli/git": "^5.0.8",
"@npmcli/mock-globals": "^1.0.0",
"@npmcli/mock-registry": "^1.0.0",
"@npmcli/template-oss": "4.22.0",
Expand Down

0 comments on commit 1c8d41d

Please sign in to comment.