Download internal/node-utils/src/git.ts from binhugg3/admin: direct link, hf CLI and curl.
- Browser
- Download file 792 Bytes
-
https://huggingface.co/spaces/binhugg3/admin/resolve/main/internal/node-utils/src/git.ts
- Command line
-
hf download hf://spaces/binhugg3/admin/internal/node-utils/src/git.ts
-
curl -L -o git.ts https://huggingface.co/spaces/binhugg3/admin/resolve/main/internal/node-utils/src/git.ts
792 Bytes
| import path from 'node:path'; | |
| import { execa } from 'execa'; | |
| export * from '@changesets/git'; | |
| /** | |
| * 获取暂存区文件 | |
| */ | |
| async function getStagedFiles(): Promise<string[]> { | |
| try { | |
| const { stdout } = await execa('git', [ | |
| '-c', | |
| 'submodule.recurse=false', | |
| 'diff', | |
| '--staged', | |
| '--diff-filter=ACMR', | |
| '--name-only', | |
| '--ignore-submodules', | |
| '-z', | |
| ]); | |
| let changedList = stdout ? stdout.replace(/\0$/, '').split('\0') : []; | |
| changedList = changedList.map((item) => path.resolve(process.cwd(), item)); | |
| const changedSet = new Set(changedList); | |
| changedSet.delete(''); | |
| return [...changedSet]; | |
| } catch (error) { | |
| console.error('Failed to get staged files:', error); | |
| return []; | |
| } | |
| } | |
| export { getStagedFiles }; | |