Library to do git operations to find changed files in a given git repository.
Minimum git version of 2.20.0 must already be installed on the host machine.
To build run
pnpm install
pnpm buildJest unit tests can be run with
pnpm testPrerequisite: The head mus tbe set on the repo otherwise any functions using default branch will fail
npm i @apexdevtools/git-opsGetting changed files using the default branch in that repo given a ref. This finds the default branch in the repo using git symbolic-ref 'refs/remotes/origin/HEAD' so the HEAD must be set.
The output of the command is same as running git diff branchName...ref combined with git status.
Note: files with the status of deleted (D) and ignored (!) will not be included in the change set.
Works out changed files using the default branch in that repo given a ref.
This find the default branch in the repo using git symbolic-ref 'refs/remotes/origin/HEAD'
so the HEAD must be set. The output of the command is same as running git diff branchName...ref combined with git status.
Files with the status of deleted (D) and ignored (!) will not be included in the change set.
getDefaultBranchDiffByRef(repoDir: string, ref: string): Promise<Set<string>>This command is same as calling getDefaultBranchDiffByRef(repoRootDir, 'HEAD').
getDefaultBranchDiff(repoDir: string): Promise<Set<string>>Works out the diff between a given range. Equivalent to git diff ref1...ref2
getDiffRange(dir: string, fromRef: string, toRef: string): Promise<Set<string>>Get the local changes that not have been committed. Equivalent to git status
Files with the status of deleted (D) and ignored (!) will not be included in the change set
getLocalChanges(dir: string): Promise<Set<string>>