Skip to content

Commit 2689570

Browse files
author
ityaozm@gmail.com
committed
feat(commit): add optional diff parameter for commit command
- Introduced an optional 'diff' parameter to allow users to specify diff content directly. - Updated the command to use the provided diff option if available, enhancing flexibility. - Ensured that if no diff is specified, the command defaults to the previous behavior.
1 parent 08e410c commit 2689570

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

app/Commands/CommitCommand.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function handle(): void
6666
// Ensure git is installed and the current directory is a git repository.
6767
$this->createProcess(['git', 'rev-parse', '--is-inside-work-tree'])->mustRun();
6868

69-
$cachedDiff = $this->createProcess($this->getDiffCommand())->mustRun()->getOutput();
69+
$cachedDiff = $this->option('diff') ?: $this->createProcess($this->getDiffCommand())->mustRun()->getOutput();
7070
if ('' === $cachedDiff) {
7171
throw new TaskException('There are no cached files to commit. Try running `git add` to cache some files.');
7272
}
@@ -234,6 +234,12 @@ protected function configure(): void
234234
InputOption::VALUE_NONE,
235235
'Only generate message without commit',
236236
),
237+
new InputOption(
238+
'diff',
239+
null,
240+
InputOption::VALUE_OPTIONAL,
241+
'Specify diff content',
242+
),
237243
]);
238244
}
239245

0 commit comments

Comments
 (0)