Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
git-changed-files
Advanced tools
Get the change between any of your branch and current branch of a `git` repository
Get the committed and uncommitted files list between your any of your branch and current branch of a
git
repository
To add it to devDependencies
yarn add git-changed-files --dev
or
npm install --save-dev git-changed-files
const gitChangedFiles = require('git-changed-files');
(async() => {
let committedGitFiles = await gitChangedFiles();
console.log(committedGitFiles);
})().catch((err) => {
console.log(err);
});
/* Expected: { committedFiles: [ '.editorconfig', '.travis.yml', 'destroy.js', 'index.js' ],
unCommittedFiles: ['index.js'] }
*/
(async() => {
let committedGitFiles = await gitChangedFiles({ formats: ['*.yml'] });
console.log(committedGitFiles);
})().catch((err) => {
console.log(err);
});
/* Expected: { committedFiles: [ '.travis.yml'],
unCommittedFiles: [] }
*/
(async() => {
let committedGitFiles = await gitChangedFiles({ formats: ['!*.yml'] });
console.log(committedGitFiles);
})().catch((err) => {
console.log(err);
});
/* Expected: { committedFiles: [ '.editorconfig', 'destroy.js', 'index.js' ],
unCommittedFiles: ['index.js'] }
*/
(async() => {
let committedGitFiles = await gitChangedFiles({ diffFilter: 'A' });
console.log(committedGitFiles);
})().catch((err) => {
console.log(err);
});
/* Expected: { committedFiles: ['destroy.js'],
unCommittedFiles: [] }
*/
(async() => {
let committedGitFiles = await gitChangedFiles({ showStatus: true });
console.log(committedGitFiles);
})().catch((err) => {
console.log(err);
});
/*
Expected:
{
committedFiles: [
{
fileName: '.editorconfig',
status: 'Modified'
},
{
fileName: '.travis.yml'
status: 'Modified'
},
{
fileName: 'destroy.js'
status: 'Added'
},
{
fileName: 'index.js'
status: 'Modified'
}
],
unCommittedFiles: [
{
fileName: 'index.js'
status: 'Modified'
}
]
}
*/
(async() => {
let uncommittedGitFiles = await gitChangedFiles({ showCommitted: false });
console.log(uncommittedGitFiles);
})().catch((err) => {
console.log(err);
});
// Expected: { unCommittedFiles: ['index.js'] }
(async() => {
let committedGitFiles = await gitChangedFiles({ showUnCommitted: false });
console.log(committedGitFiles);
})().catch((err) => {
console.log(err);
});
// Expected: { committedFiles: [ '.editorconfig', '.travis.yml', 'destroy.js', 'index.js' ] }
Returns Promise<Array[]|String>
.
Type: Object
Type: string
Default: master
baseBranch to compare with you current HEAD.
Example: if baseBranch is master, then the list of files that are changed from master to your current HEAD in local will be displayed.
Type: string
| string[]
Default: false
Filters passed filetypes. If need all filetypes pass false
or specify the filetypes in array.
Example:
[*.js]
[!*.js]
Type: string
Default: ACDMRTUXB
Diff filters :
Refer More here
Type: boolean
Default: false
To show the type of file change in the result.
Example: If showStatus is true then output will be
[{ filename: '.editorconfig', status: 'Deleted' }]
Type: boolean
Default: true
Examples:
Case 1:
By default, it lists all the changed files.
{ committedFiles: [ '.editorconfig', '.travis.yml', 'destroy.js', 'index.js' ], unCommittedFiles: ['index.js'] }
Case 2:
If showUnCommitted
is false then output will be
{ committedFiles: [ '.editorconfig', '.travis.yml', 'destroy.js', 'index.js' ] }
Case 3:
If showCommitted
is false then output will be
{ unCommittedFiles: ['index.js'] }
Case 4:
If both options are false then it will throw an error.
Either showCommitted or showUnCommitted must be true
If you changed a file and committed then again if you changed the same file, it will be present in both committed and uncommitted files list.
MIT
FAQs
Get the change between any of your branch and current branch of a `git` repository
The npm package git-changed-files receives a total of 8,588 weekly downloads. As such, git-changed-files popularity was classified as popular.
We found that git-changed-files demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.