Skip to content

Commit

Permalink
Include dotfiles in delete commit (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
ofhouse authored May 4, 2021
1 parent 0ed35f6 commit 56d32ea
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/git-strip-merge.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ module.exports = async function gitStripMerge(
// Get all files that should be excluded
const files = await globby(excludePaths, {
cwd,
// Include files that start with a dot (e.g. .gitignore)
dot: true,
});

// Running git rm without any paths would fail
Expand Down
23 changes: 23 additions & 0 deletions test/git-strip-merge.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,27 @@ describe('git strip merge', () => {
commitCount = await git.raw(['rev-list', '--count', releaseBranch]);
expect(Number(commitCount)).toBe(4);
});

test('Dotfiles', async () => {
const excludePaths = ['src/**/*'];

createFile('main.tf', baseDir);
createFile('src/some/path/.gitignore', baseDir);
createFile('src/some/other/path/.gitkeep', baseDir);
expect(fileExists('main.tf')).toBeTruthy();
expect(fileExists('src/some/path/.gitignore')).toBeTruthy();
expect(fileExists('src/some/other/path/.gitkeep')).toBeTruthy();
await git.add('.').commit('Commit 1');

// Run strip merge
await git.checkout(releaseBranch);
await gitStripMerge(git, baseBranch, excludePaths);

// Total number of commits should be 4
let commitCount = await git.raw(['rev-list', '--count', releaseBranch]);
expect(Number(commitCount)).toBe(4);

expect(fileExists('src/some/path/.gitignore')).toBeFalsy();
expect(fileExists('src/some/other/path/.gitkeep')).toBeFalsy();
});
});

0 comments on commit 56d32ea

Please sign in to comment.