Skip to content

Commit 9219cd9

Browse files
committed
Merge branch 'upstream-development'
2 parents 9afc924 + f80c82c commit 9219cd9

File tree

13 files changed

+95
-75
lines changed

13 files changed

+95
-75
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"prettier.singleQuote": true,
2727
"prettier.trailingComma": "es5",
2828
"editor.formatOnSave": true,
29+
"prettier.prettierPath": "./node_modules/prettier",
2930
"editor.codeActionsOnSave": {
3031
"source.organizeImports": "never"
3132
},

app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"productName": "GitHub Desktop Plus",
55
"bundleID": "com.github.GitHubClient",
66
"companyName": "GitHub, Inc.",
7-
"version": "3.5.5-beta3",
7+
"version": "3.5.5-beta4",
88
"main": "./main.js",
99
"repository": {
1010
"type": "git",

app/src/lib/feature-flag.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,5 @@ export function enableAccessibleListToolTips(): boolean {
108108
}
109109

110110
export const enableHooksEnvironment = enableBetaFeatures
111+
112+
export const enableHooksByDefault = enableBetaFeatures

app/src/lib/git/core.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,17 @@ export type TerminalOutputListener = (cb: (chunk: TerminalOutput) => void) => {
3535

3636
export type TerminalOutputCallback = (subscribe: TerminalOutputListener) => void
3737

38-
export type HookProgress =
38+
export type HookProgress = {
39+
readonly hookName: string
40+
} & (
3941
| {
40-
readonly hookName: string
41-
} & (
42-
| {
43-
readonly status: 'started'
44-
readonly abort: () => void
45-
}
46-
| {
47-
readonly status: 'finished' | 'failed'
48-
}
49-
)
42+
readonly status: 'started'
43+
readonly abort: () => void
44+
}
45+
| {
46+
readonly status: 'finished' | 'failed'
47+
}
48+
)
5049

5150
export type HookCallbackOptions = {
5251
readonly onHookProgress?: (progress: HookProgress) => void

app/src/lib/git/rebase.ts

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
gitRebaseArguments,
2222
IGitStringExecutionOptions,
2323
IGitStringResult,
24+
HookCallbackOptions,
2425
} from './core'
2526
import { stageManualConflictResolution } from './stage'
2627
import { stageFiles } from './update-index'
@@ -438,8 +439,7 @@ export async function continueRebase(
438439
repository: Repository,
439440
files: ReadonlyArray<WorkingDirectoryFileChange>,
440441
manualResolutions: ReadonlyMap<string, ManualConflictResolution> = new Map(),
441-
progressCallback?: (progress: IMultiCommitOperationProgress) => void,
442-
gitEditor: string = ':'
442+
opts?: RebaseInteractiveOptions
443443
): Promise<RebaseResult> {
444444
const trackedFiles = files.filter(f => {
445445
return f.status.kind !== AppFileStatusKind.Untracked
@@ -484,13 +484,13 @@ export async function continueRebase(
484484
GitError.UnresolvedConflicts,
485485
]),
486486
env: {
487-
GIT_EDITOR: gitEditor,
487+
GIT_EDITOR: opts?.gitEditor ?? ':',
488488
},
489489
}
490490

491491
let options = baseOptions
492492

493-
if (progressCallback !== undefined) {
493+
if (opts?.progressCallback) {
494494
const snapshot = await getRebaseSnapshot(repository)
495495

496496
if (snapshot === null) {
@@ -502,17 +502,24 @@ export async function continueRebase(
502502

503503
options = configureOptionsForRebase(baseOptions, {
504504
commits: snapshot.commits,
505-
progressCallback,
505+
progressCallback: opts.progressCallback,
506506
})
507507
}
508508

509+
options = {
510+
...options,
511+
onTerminalOutputAvailable: opts?.onTerminalOutputAvailable,
512+
onHookFailure: opts?.onHookFailure,
513+
onHookProgress: opts?.onHookProgress,
514+
}
515+
509516
if (trackedFilesAfter.length === 0) {
510517
log.warn(
511518
`[rebase] no tracked changes to commit for ${rebaseCurrentCommit}, continuing rebase but skipping this commit`
512519
)
513520

514521
const result = await git(
515-
['rebase', '--skip'],
522+
['rebase', '--skip', ...(opts?.noVerify ? ['--no-verify'] : [])],
516523
repository.path,
517524
'continueRebaseSkipCurrentCommit',
518525
options
@@ -522,7 +529,7 @@ export async function continueRebase(
522529
}
523530

524531
const result = await git(
525-
['rebase', '--continue'],
532+
['rebase', '--continue', ...(opts?.noVerify ? ['--no-verify'] : [])],
526533
repository.path,
527534
'continueRebase',
528535
options
@@ -531,6 +538,22 @@ export async function continueRebase(
531538
return parseRebaseResult(result)
532539
}
533540

541+
export type RebaseInteractiveOptions = {
542+
/**
543+
* a description of the action to be displayed in the progress dialog - i.e. Squash, Amend, etc..
544+
*/
545+
action?: string
546+
547+
/**
548+
* the GIT_EDITOR environment variable to use during the interactive rebase,
549+
* defaults to ':' which is a no-op command
550+
*/
551+
gitEditor?: string
552+
progressCallback?: (progress: IMultiCommitOperationProgress) => void
553+
commits?: ReadonlyArray<Commit>
554+
noVerify?: boolean
555+
} & HookCallbackOptions
556+
534557
/**
535558
* Method for initiating interactive rebase in the app.
536559
*
@@ -543,30 +566,27 @@ export async function continueRebase(
543566
* @param lastRetainedCommitRef the commit before the earliest commit to be
544567
* changed during the interactive rebase or null if commit is root (first commit
545568
* in history) of branch
546-
* @param action a description of the action to be displayed in the progress
547-
* dialog - i.e. Squash, Amend, etc..
548569
*/
549570
export async function rebaseInteractive(
550571
repository: Repository,
551572
pathOfGeneratedTodo: string,
552573
lastRetainedCommitRef: string | null,
553-
action: string = 'Interactive rebase',
554-
gitEditor: string = ':',
555-
progressCallback?: (progress: IMultiCommitOperationProgress) => void,
556-
commits?: ReadonlyArray<Commit>
574+
opts?: RebaseInteractiveOptions
557575
): Promise<RebaseResult> {
558576
const baseOptions: IGitStringExecutionOptions = {
559577
expectedErrors: new Set([GitError.RebaseConflicts]),
560578
env: {
561579
GIT_SEQUENCE_EDITOR: undefined,
562-
GIT_EDITOR: gitEditor,
580+
GIT_EDITOR: opts?.gitEditor ?? ':',
563581
},
564582
}
565583

566584
let options = baseOptions
567585

568-
if (progressCallback !== undefined) {
569-
if (commits === undefined) {
586+
const { progressCallback, commits } = opts ?? {}
587+
588+
if (progressCallback) {
589+
if (!commits) {
570590
log.warn(`Unable to interactively rebase if no commits`)
571591
return RebaseResult.Error
572592
}
@@ -577,6 +597,13 @@ export async function rebaseInteractive(
577597
})
578598
}
579599

600+
options = {
601+
...options,
602+
onHookProgress: opts?.onHookProgress,
603+
onHookFailure: opts?.onHookFailure,
604+
onTerminalOutputAvailable: opts?.onTerminalOutputAvailable,
605+
}
606+
580607
/* If the commit is the first commit in the branch, we cannot reference it
581608
using the sha thus if lastRetainedCommitRef is null (we couldn't define it),
582609
we must use the --root flag */
@@ -587,11 +614,12 @@ export async function rebaseInteractive(
587614
// This replaces interactive todo with contents of file at pathOfGeneratedTodo
588615
`sequence.editor=cat "${pathOfGeneratedTodo}" >`,
589616
'rebase',
617+
...(opts?.noVerify ? ['--no-verify'] : []),
590618
'-i',
591619
ref,
592620
],
593621
repository.path,
594-
action,
622+
opts?.action ?? 'Interactive rebase',
595623
options
596624
)
597625

app/src/lib/git/reorder.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,11 @@ export async function reorder(
134134
repository,
135135
todoPath,
136136
lastRetainedCommitRef,
137-
MultiCommitOperationKind.Reorder,
138-
undefined,
139-
progressCallback,
140-
commits
137+
{
138+
action: MultiCommitOperationKind.Reorder,
139+
progressCallback,
140+
commits,
141+
}
141142
)
142143
} catch (e) {
143144
log.error(e)

app/src/lib/git/squash.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,12 @@ export async function squash(
149149
repository,
150150
todoPath,
151151
lastRetainedCommitRef,
152-
MultiCommitOperationKind.Squash,
153-
gitEditor,
154-
progressCallback,
155-
[...toSquash, squashOnto]
152+
{
153+
action: MultiCommitOperationKind.Squash,
154+
gitEditor,
155+
progressCallback,
156+
commits: [...toSquash, squashOnto],
157+
}
156158
)
157159
} catch (e) {
158160
log.error(e)

app/src/lib/hooks/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { enableHooksEnvironment } from '../feature-flag'
1+
import { enableHooksByDefault, enableHooksEnvironment } from '../feature-flag'
22
import { getBoolean, setBoolean } from '../local-storage'
33

4-
export const defaultHooksEnvEnabledValue = false
4+
export const defaultHooksEnvEnabledValue = enableHooksByDefault()
55

66
/**
77
* Whether the hooks environment is enabled, takes into account the

app/src/lib/stores/app-store.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6125,12 +6125,9 @@ export class AppStore extends TypedBaseStore<IAppState> {
61256125

61266126
const gitStore = this.gitStoreCache.get(repository)
61276127
const result = await gitStore.performFailableOperation(() =>
6128-
continueRebase(
6129-
repository,
6130-
workingDirectory.files,
6131-
manualResolutions,
6132-
progressCallback
6133-
)
6128+
continueRebase(repository, workingDirectory.files, manualResolutions, {
6129+
progressCallback,
6130+
})
61346131
)
61356132

61366133
return result || RebaseResult.Error

app/test/unit/git/rebase/progress-test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ describe('git/rebase', () => {
187187
async function resolveAndContinue(
188188
repository: Repository,
189189
strategy: ManualConflictResolution,
190-
progressCb: (progress: IMultiCommitOperationProgress) => void
190+
progressCallback: (progress: IMultiCommitOperationProgress) => void
191191
) {
192192
const status = await getStatus(repository)
193193
const files = status?.workingDirectory.files ?? []
@@ -199,5 +199,7 @@ async function resolveAndContinue(
199199
}
200200
}
201201

202-
return continueRebase(repository, files, resolutions, progressCb)
202+
return continueRebase(repository, files, resolutions, {
203+
progressCallback,
204+
})
203205
}

0 commit comments

Comments
 (0)