mirror of
https://github.com/PaulHatch/semantic-version.git
synced 2025-12-27 13:08:17 +00:00
Fix change tracking when no previous tag exists
This commit is contained in:
parent
e7dede1b52
commit
bfa36c6087
3 changed files with 28 additions and 5 deletions
9
dist/index.js
vendored
9
dist/index.js
vendored
|
|
@ -1091,8 +1091,13 @@ async function run() {
|
|||
const log = await cmd(logCommand);
|
||||
|
||||
if (changePath !== '') {
|
||||
const changedFiles = await cmd(`git diff --name-only ${(root === '' ? branch : `${root}..${branch}`)} -- ${changePath}`);
|
||||
changed = changedFiles.length > 0;
|
||||
if (root === '') {
|
||||
const changedFiles = await cmd(`git log --name-only --oneline ${branch} -- ${changePath}`);
|
||||
changed = changedFiles.length > 0;
|
||||
} else {
|
||||
const changedFiles = await cmd(`git diff --name-only ${root}..${branch} -- ${changePath}`);
|
||||
changed = changedFiles.length > 0;
|
||||
}
|
||||
}
|
||||
|
||||
let history = log
|
||||
|
|
|
|||
9
index.js
9
index.js
|
|
@ -145,8 +145,13 @@ async function run() {
|
|||
const log = await cmd(logCommand);
|
||||
|
||||
if (changePath !== '') {
|
||||
const changedFiles = await cmd(`git diff --name-only ${(root === '' ? branch : `${root}..${branch}`)} -- ${changePath}`);
|
||||
changed = changedFiles.length > 0;
|
||||
if (root === '') {
|
||||
const changedFiles = await cmd(`git log --name-only --oneline ${branch} -- ${changePath}`);
|
||||
changed = changedFiles.length > 0;
|
||||
} else {
|
||||
const changedFiles = await cmd(`git diff --name-only ${root}..${branch} -- ${changePath}`);
|
||||
changed = changedFiles.length > 0;
|
||||
}
|
||||
}
|
||||
|
||||
let history = log
|
||||
|
|
|
|||
|
|
@ -331,6 +331,19 @@ test('Changes to monitored path is false when changes are not in path', () => {
|
|||
repo.clean();
|
||||
});
|
||||
|
||||
test('Changes can be detected without tags', () => {
|
||||
const repo = createTestRepo({ tag_prefix: '' }); // 0.0.0
|
||||
|
||||
repo.makeCommit('Initial Commit'); // 0.0.1
|
||||
repo.exec('mkdir project1');
|
||||
repo.makeCommit(`Second Commit`, 'project1'); // 0.0.2
|
||||
const result = repo.runAction({ change_path: "project1" });
|
||||
|
||||
expect(result).toMatch('::set-output name=changed::true');
|
||||
|
||||
repo.clean();
|
||||
});
|
||||
|
||||
test('Changes to multiple monitored path is true when change is in path', () => {
|
||||
const repo = createTestRepo({ tag_prefix: '' }); // 0.0.0
|
||||
|
||||
|
|
@ -339,7 +352,7 @@ test('Changes to multiple monitored path is true when change is in path', () =>
|
|||
repo.exec('mkdir project1');
|
||||
repo.exec('mkdir project2');
|
||||
repo.makeCommit(`Second Commit`, 'project2'); // 0.0.2
|
||||
const result = repo.runAction({ change_path: "./project1 ./project2" });
|
||||
const result = repo.runAction({ change_path: "project1 project2" });
|
||||
|
||||
expect(result).toMatch('::set-output name=changed::true');
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue