Skip to content

Commit 46efbf9

Browse files
committed
Support staging all working tree changes when generating commit messages from source control
1 parent 7ba0464 commit 46efbf9

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

‎apps/editor/src/commands/generate-commit-message-command/generate-commit-message-command.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const generate_commit_message_command = (
2121
const working_tree_changes = repository.state.workingTreeChanges || []
2222
const is_single_change = was_empty_stage && working_tree_changes.length == 1
2323

24-
const diff = await prepare_staged_changes(repository)
24+
const diff = await prepare_staged_changes(repository, !!source_control)
2525

2626
if (!diff) return null
2727

@@ -55,7 +55,8 @@ export const generate_commit_message_command = (
5555
await api_providers_manager.get_default_commit_messages_config()
5656
const has_default_config = !!default_config
5757

58-
const show_back_button = was_empty_stage && !is_single_change_flow
58+
const show_back_button =
59+
was_empty_stage && !is_single_change_flow && !source_control
5960

6061
const api_config_data = await get_commit_message_config(
6162
context,

‎apps/editor/src/utils/git-repository-utils.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ export const get_git_repository = async (
8787
}
8888

8989
export const prepare_staged_changes = async (
90-
repository: GitRepository
90+
repository: GitRepository,
91+
stage_all_if_none_staged: boolean = false
9192
): Promise<string | null> => {
9293
await repository.status()
9394
const staged_changes = repository.state.indexChanges || []
@@ -98,7 +99,11 @@ export const prepare_staged_changes = async (
9899
) {
99100
let files_to_stage: string[] = []
100101

101-
if (repository.state.workingTreeChanges.length == 1) {
102+
if (stage_all_if_none_staged) {
103+
files_to_stage = repository.state.workingTreeChanges.map(
104+
(change: any) => change.uri.fsPath
105+
)
106+
} else if (repository.state.workingTreeChanges.length == 1) {
102107
files_to_stage = [repository.state.workingTreeChanges[0].uri.fsPath]
103108
} else {
104109
const items = repository.state.workingTreeChanges.map((change: any) => {

0 commit comments

Comments
 (0)