{"name":"@npmcli/git","version":"8.0.0","author":{"name":"GitHub Inc."},"license":"ISC","_id":"@npmcli/git@8.0.0","maintainers":[{"name":"saquibkhan","email":"saquibkhan@github.com"},{"name":"npm-cli-ops","email":"npm-cli+bot@github.com"},{"name":"reggi","email":"reggi@github.com"},{"name":"owlstronaut","email":"owlstronaut@github.com"}],"homepage":"https://github.com/npm/git#readme","bugs":{"url":"https://github.com/npm/git/issues"},"tap":{"nyc-arg":["--exclude","tap-snapshots/**"],"timeout":600},"dist":{"shasum":"1afc0a23ab41b9bf3612e9323471ff249617fa4e","tarball":"http://registry-npm.ywwl.com/@npmcli/git/download/@npmcli/git-8.0.0.tgz","fileCount":16,"integrity":"sha512-5P1oo+TbxZNAiiMBtpzHA8QyEGh5D69LYLexNWJEDXLdxnAZvT/SLitGJBXxjtCE4ftAcFOS/Tu2185MeIjooQ==","signatures":[{"sig":"MEUCIQCn7iHNGuwmIrNL31ifZtIYIqBJ2PE+5ClQrqZ7ZRMptwIgfLfCEv74O3jyKcHCu+vehlMBEAaWOaT5N6JRLbT/dXA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@npmcli%2fgit@8.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":22961,"size":8959,"noattachment":false,"key":"/@npmcli/git/-/@npmcli/git-8.0.0.tgz"},"main":"lib/index.js","engines":{"node":"^22.22.2 || ^24.15.0 || >=26.0.0"},"gitHead":"5c8dc2a51721a659f6641142ce86d4c83bce60a0","scripts":{"lint":"npm run eslint","snap":"tap","test":"tap","eslint":"eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"","lintfix":"npm run eslint -- --fix","postlint":"template-oss-check","posttest":"npm run lint","template-oss-apply":"template-oss-apply --force"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:c6490f80-20d2-4fcc-8b52-50b6d93b6ea6"}},"repository":{"url":"git+https://github.com/npm/git.git","type":"git"},"_npmVersion":"11.13.0","description":"a util for spawning git from npm CLI contexts","directories":{},"templateOSS":{"publish":true,"version":"5.1.0","updateNpm":false,"//@npmcli/template-oss":"This file is partially managed by @npmcli/template-oss. Edits may be overwritten."},"_nodeVersion":"26.1.0","dependencies":{"ini":"^7.0.0","which":"^7.0.0","semver":"^7.3.5","proc-log":"^7.0.0","lru-cache":"^11.2.1","npm-pick-manifest":"^12.0.0","@gar/promise-retry":"^1.0.0","@npmcli/promise-spawn":"^10.0.0"},"_hasShrinkwrap":false,"devDependencies":{"tap":"^16.0.1","slash":"^3.0.0","npm-package-arg":"^14.0.0","@npmcli/template-oss":"5.1.0","@npmcli/eslint-config":"^7.0.0"},"_npmOperationalInternal":{"tmp":"tmp/git_8.0.0_1779205032498_0.22568645245870855","host":"s3://npm-registry-packages-npm-production"},"readme":"# @npmcli/git\n\nA utility for spawning git from npm CLI contexts.\n\nThis is _not_ an implementation of git itself, it's just a thing that\nspawns child processes to tell the system git CLI implementation to do\nstuff.\n\n## USAGE\n\n```js\nconst git = require('@npmcli/git')\ngit.clone('git://foo/bar.git', 'some-branch', 'some-path', opts) // clone a repo\n  .then(() => git.spawn(['checkout', 'some-branch'], {cwd: 'bar'}))\n  .then(() => git.spawn(['you get the idea']))\n```\n\n## API\n\nMost methods take an options object.  Options are described below.\n\n### `git.spawn(args, opts = {})`\n\nLaunch a `git` subprocess with the arguments specified.\n\nAll the other functions call this one at some point.\n\nProcesses are launched using\n[`@npmcli/promise-spawn`](http://npm.im/@npmcli/promise-spawn), with the\n`stdioString: true` option enabled by default, since git output is\ngenerally in readable string format.\n\nReturn value is a `Promise` that resolves to a result object with `{cmd,\nargs, code, signal, stdout, stderr}` members, or rejects with an error with\nthe same fields, passed back from\n[`@npmcli/promise-spawn`](http://npm.im/@npmcli/promise-spawn).\n\n### `git.clone(repo, ref = 'HEAD', target = null, opts = {})` -> `Promise<sha String>`\n\nClone the repository into `target` path (or the default path for the name\nof the repository), checking out `ref`.\n\nReturn value is the sha of the current HEAD in the locally cloned\nrepository.\n\nIn lieu of a specific `ref`, you may also pass in a `spec` option, which is\na [`npm-package-arg`](http://npm.im/npm-package-arg) object for a `git`\npackage dependency reference.  In this way, you can select SemVer tags\nwithin a range, or any git committish value.  For example:\n\n```js\nconst npa = require('npm-package-arg')\ngit.clone('git@github.com:npm/git.git', '', null, {\n  spec: npa('github:npm/git#semver:1.x'),\n})\n\n// only gitRange and gitCommittish are relevant, so this works, too\ngit.clone('git@github.com:npm/git.git', null, null, {\n  spec: { gitRange: '1.x' }\n})\n```\n\nThis will automatically do a shallow `--depth=1` clone on any hosts that\nare known to support it.  To force a shallow or deep clone, you can set the\n`gitShallow` option to `true` or `false` respectively.\n\n### `git.revs(repo, opts = {})` -> `Promise<rev doc Object>`\n\nFetch a representation of all of the named references in a given\nrepository.  The resulting doc is intentionally somewhat\n[packument](https://www.npmjs.com/package/pacote#packuments)-like, so that\ngit semver ranges can be applied using the same\n[`npm-pick-manifest`](http://npm.im/npm-pick-manifest) logic.\n\nThe resulting object looks like:\n\n```js\nrevs = {\n  versions: {\n    // all semver-looking tags go in here...\n    // version: { sha, ref, rawRef, type }\n    '1.0.0': {\n      sha: '1bc5fba3353f8e1b56493b266bc459276ab23139',\n      ref: 'v1.0.0',\n      rawRef: 'refs/tags/v1.0.0',\n      type: 'tag',\n    },\n  },\n  'dist-tags': {\n    HEAD: '1.0.0',\n    latest: '1.0.0',\n  },\n  refs: {\n    // all the advertised refs that can be cloned down remotely\n    HEAD: { sha, ref, rawRef, type: 'head' },\n    master: { ... },\n    'v1.0.0': { ... },\n    'refs/tags/v1.0.0': { ... },\n  },\n  shas: {\n    // all named shas referenced above\n    // sha: [list, of, refs]\n    '6b2501f9183a1753027a9bf89a184b7d3d4602c7': [\n      'HEAD',\n      'master',\n      'refs/heads/master',\n    ],\n    '1bc5fba3353f8e1b56493b266bc459276ab23139': [ 'v1.0.0', 'refs/tags/v1.0.0' ],\n  },\n}\n```\n\n### `git.is(opts)` -> `Promise<Boolean>`\n\nResolve to `true` if the path argument refers to the root of a git\nrepository.\n\nIt does this by looking for a file in `${path}/.git/index`, which is not an\nairtight indicator, but at least avoids being fooled by an empty directory\nor a file named `.git`.\n\n### `git.find(opts)` -> `Promise<String | null>`\n\nGiven a path, walk up the file system tree until a git repo working\ndirectory is found.  Since this calls `stat` a bunch of times, it's\nprobably best to only call it if you're reasonably sure you're likely to be\nin a git project somewhere. Pass in `opts.root` to stop checking at that\ndirectory.\n\nResolves to `null` if not in a git project.\n\n### `git.isClean(opts = {})` -> `Promise<Boolean>`\n\nReturn true if in a git dir, and that git dir is free of changes.  This\nwill resolve `true` if the git working dir is clean, or `false` if not, and\nreject if the path is not within a git directory or some other error\noccurs.\n\n## OPTIONS\n\n- `retry` An object to configure retry behavior for transient network\n  errors with exponential backoff.\n  - `retries`: Defaults to `opts.fetchRetries` or 2\n  - `factor`: Defaults to `opts.fetchRetryFactor` or 10\n  - `maxTimeout`: Defaults to `opts.fetchRetryMaxtimeout` or 60000\n  - `minTimeout`: Defaults to `opts.fetchRetryMintimeout` or 1000\n- `git` Path to the `git` binary to use.  Will look up the first `git` in\n  the `PATH` if not specified.\n- `spec` The [`npm-package-arg`](http://npm.im/npm-package-arg) specifier\n  object for the thing being fetched (if relevant).\n- `fakePlatform` set to a fake value of `process.platform` to use.  (Just\n  for testing `win32` behavior on Unix, and vice versa.)\n- `cwd` The current working dir for the git command.  Particularly for\n  `find` and `is` and `isClean`, it's good to know that this defaults to\n  `process.cwd()`, as one might expect.\n- Any other options that can be passed to\n  [`@npmcli/promise-spawn`](http://npm.im/@npmcli/promise-spawn), or\n  `child_process.spawn()`.\n","publish_time":1779205032643,"_cnpm_publish_time":1779205032643,"dist-tags":{"latest":"8.0.0"}}