Skip to content

Commit ebebddb

Browse files
committed
compare-screenshots: allow omitting dot for current directory
As a convenience, @Head~2 is now equivalent to .@Head~2, meaning the current directory will be used as the worktree. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 8d47c54 commit ebebddb

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

script/compare-screenshots.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Options:
2020
Examples:
2121
node script/compare-screenshots.js https://git-scm.com http://localhost:5000
2222
node script/compare-screenshots.js https://git-scm.com /path/to/worktree
23-
node script/compare-screenshots.js https://git-scm.com .@HEAD~2
23+
node script/compare-screenshots.js https://git-scm.com @HEAD~2
2424
node script/compare-screenshots.js https://git-scm.com/docs/git-config /path/to/worktree:/docs/git-config
2525
node script/compare-screenshots.js --dark https://git-scm.com http://localhost:5000
2626
node script/compare-screenshots.js --clip=1280x720+0+0 https://git-scm.com http://localhost:5000`;
@@ -33,10 +33,11 @@ const path = require('path');
3333
/**
3434
* Parse a worktree argument to extract worktree path, commit, and page path.
3535
*
36-
* Format: worktree[@commit][:/page/path]
36+
* Format: [worktree][@commit][:/page/path]
3737
*
3838
* Examples:
3939
* . -> { worktreePath: '.', commit: undefined, pagePath: '' }
40+
* @HEAD~2 -> { worktreePath: '.', commit: 'HEAD~2', pagePath: '' }
4041
* .@HEAD~2 -> { worktreePath: '.', commit: 'HEAD~2', pagePath: '' }
4142
* /path/to/worktree:/docs/git -> { worktreePath: '/path/to/worktree', commit: undefined, pagePath: 'docs/git' }
4243
* .@main:/about -> { worktreePath: '.', commit: 'main', pagePath: 'about' }
@@ -45,6 +46,8 @@ const path = require('path');
4546
*/
4647
function getWorktreeInfo(arg) {
4748
if (arg.startsWith('http://') || arg.startsWith('https://')) return false;
49+
// Allow @commit as shorthand for .@commit (current directory)
50+
if (arg.startsWith('@')) arg = '.' + arg;
4851
const colonIndex = arg.indexOf(':');
4952
const beforeColon = colonIndex === -1 ? arg : arg.slice(0, colonIndex);
5053
const pagePath = colonIndex === -1 ? '' : arg.slice(colonIndex + 1).replace(/^\/+/, '');

0 commit comments

Comments
 (0)