Skip to content
This repository was archived by the owner on Jun 15, 2024. It is now read-only.

Commit 90645e0

Browse files
committed
feat(sync): Synchronize updates 4731f27676bdd2871eb9033efc498c974cf6d863
1 parent 95dd683 commit 90645e0

File tree

12 files changed

+97
-38
lines changed

12 files changed

+97
-38
lines changed

Original-README-ZH.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ GitHub app. 它是用 [TypeScript](https://www.typescriptlang.org) 和 [React](h
77

88
## 这是一个什么项目?
99

10-
这是一个把github desktop翻译成中文的项目, 当前翻译版本[release-3.1.2](https://github.com/gouzil/github-desktop-zh/tree/release-3.1.2)
10+
这是一个把github desktop翻译成中文的项目, 当前翻译版本[release-3.1.3](https://github.com/gouzil/github-desktop-zh/tree/release-3.1.3)
1111

1212
## 在哪里可以下载到?
1313

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
## 这是一个什么项目?
2525

26-
这是一个把github desktop翻译成中文的项目, 当前翻译版本[release-3.1.2](https://github.com/gouzil/github-desktop-zh/tree/release-3.1.2)
26+
这是一个把github desktop翻译成中文的项目, 当前翻译版本[release-3.1.3](https://github.com/gouzil/github-desktop-zh/tree/release-3.1.3)
2727

2828
## 部分截图
2929

app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"productName": "GitHub Desktop",
44
"bundleID": "com.github.GitHubClient",
55
"companyName": "GitHub, Inc.",
6-
"version": "3.1.2",
6+
"version": "3.1.3",
77
"main": "./main.js",
88
"repository": {
99
"type": "git",

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

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6477,6 +6477,25 @@ export class AppStore extends TypedBaseStore<IAppState> {
64776477
}
64786478
}
64796479

6480+
/**
6481+
* Multi selection on the commit list can give an order of 1, 5, 3 if that is
6482+
* how the user selected them. However, we want to main chronological ordering
6483+
* of the commits to reduce the chance of conflicts during interact rebasing.
6484+
* Thus, assuming 1 is the first commit made by the user and 5 is the last. We
6485+
* want the order to be, 1, 3, 5.
6486+
*/
6487+
private orderCommitsByHistory(
6488+
repository: Repository,
6489+
commits: ReadonlyArray<CommitOneLine>
6490+
) {
6491+
const { compareState } = this.repositoryStateCache.get(repository)
6492+
const { commitSHAs } = compareState
6493+
6494+
return [...commits].sort(
6495+
(a, b) => commitSHAs.indexOf(b.sha) - commitSHAs.indexOf(a.sha)
6496+
)
6497+
}
6498+
64806499
/** This shouldn't be called directly. See `Dispatcher`. */
64816500
public async _cherryPick(
64826501
repository: Repository,
@@ -6487,13 +6506,15 @@ export class AppStore extends TypedBaseStore<IAppState> {
64876506
return CherryPickResult.UnableToStart
64886507
}
64896508

6509+
const orderedCommits = this.orderCommitsByHistory(repository, commits)
6510+
64906511
await this._refreshRepository(repository)
64916512

64926513
const progressCallback =
64936514
this.getMultiCommitOperationProgressCallBack(repository)
64946515
const gitStore = this.gitStoreCache.get(repository)
64956516
const result = await gitStore.performFailableOperation(() =>
6496-
cherryPick(repository, commits, progressCallback)
6517+
cherryPick(repository, orderedCommits, progressCallback)
64976518
)
64986519

64996520
return result || CherryPickResult.Error

app/src/ui/changes/commit-message.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ export class CommitMessage extends React.Component<
351351
if (
352352
isShortcutKey &&
353353
event.key === 'Enter' &&
354-
this.canCommit() &&
354+
(this.canCommit() || this.canAmend()) &&
355355
this.canExcecuteCommitShortcut()
356356
) {
357357
this.createCommit()

app/src/ui/history/commit-list-item.tsx

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ interface ICommitProps {
5151
readonly showUnpushedIndicator: boolean
5252
readonly unpushedIndicatorTitle?: string
5353
readonly unpushedTags?: ReadonlyArray<string>
54-
readonly isCherryPickInProgress?: boolean
5554
readonly disableSquashing?: boolean
55+
readonly isMultiCommitOperationInProgress?: boolean
5656
}
5757

5858
interface ICommitListItemState {
@@ -126,7 +126,7 @@ export class CommitListItem extends React.PureComponent<
126126
author: { date },
127127
} = commit
128128

129-
const isDraggable = this.canCherryPick()
129+
const isDraggable = this.isDraggable()
130130
const hasEmptySummary = commit.summary.length === 0
131131
const commitSummary = hasEmptySummary ? '清空提交信息' : commit.summary
132132

@@ -369,17 +369,34 @@ export class CommitListItem extends React.PureComponent<
369369
{
370370
label: __DARWIN__ ? `去除 ${count} 提交…` : `去除 ${count} 提交…`,
371371
action: this.onSquash,
372+
enabled: this.canSquash(),
372373
},
373374
]
374375
}
375376

377+
private isDraggable(): boolean {
378+
const { onCherryPick, onSquash, isMultiCommitOperationInProgress } =
379+
this.props
380+
return (
381+
(onCherryPick !== undefined || onSquash !== undefined) &&
382+
isMultiCommitOperationInProgress === false
383+
)
384+
}
385+
376386
private canCherryPick(): boolean {
377-
const { onCherryPick, isCherryPickInProgress } = this.props
387+
const { onCherryPick, isMultiCommitOperationInProgress } = this.props
378388
return (
379-
onCherryPick !== undefined &&
380-
this.onSquash !== undefined &&
381-
isCherryPickInProgress === false
382-
// TODO: isSquashInProgress === false
389+
onCherryPick !== undefined && isMultiCommitOperationInProgress === false
390+
)
391+
}
392+
393+
private canSquash(): boolean {
394+
const { onSquash, disableSquashing, isMultiCommitOperationInProgress } =
395+
this.props
396+
return (
397+
onSquash !== undefined &&
398+
disableSquashing === false &&
399+
isMultiCommitOperationInProgress === false
383400
)
384401
}
385402

app/src/ui/history/commit-list.tsx

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,9 @@ interface ICommitListProps {
119119
/** Whether or not commits in this list can be reordered. */
120120
readonly reorderingEnabled?: boolean
121121

122-
/** Whether a cherry pick is progress */
123-
readonly isCherryPickInProgress?: boolean
122+
/** Whether a multi commit operation is in progress (in particular the
123+
* conflicts resolution step allows interaction with history) */
124+
readonly isMultiCommitOperationInProgress?: boolean
124125

125126
/** Callback to render commit drag element */
126127
readonly onRenderCommitDragElement?: (
@@ -213,10 +214,12 @@ export class CommitList extends React.Component<ICommitListProps, {}> {
213214
onAmendCommit={this.props.onAmendCommit}
214215
onViewCommitOnGitHub={this.props.onViewCommitOnGitHub}
215216
selectedCommits={this.lookupCommits(this.props.selectedSHAs)}
216-
isCherryPickInProgress={this.props.isCherryPickInProgress}
217217
onRenderCommitDragElement={this.onRenderCommitDragElement}
218218
onRemoveDragElement={this.props.onRemoveCommitDragElement}
219219
disableSquashing={this.props.disableSquashing}
220+
isMultiCommitOperationInProgress={
221+
this.props.isMultiCommitOperationInProgress
222+
}
220223
/>
221224
)
222225
}
@@ -272,15 +275,9 @@ export class CommitList extends React.Component<ICommitListProps, {}> {
272275
}
273276

274277
private onSelectionChanged = (rows: ReadonlyArray<number>) => {
275-
// Multi select can give something like 1, 5, 3 depending on order that user
276-
// selects. We want to ensure they are in chronological order for best
277-
// cherry-picking results. If user wants to use cherry-picking for
278-
// reordering, they will need to do multiple cherry-picks.
279-
// Goal: first commit in history -> first on array
280-
const sorted = [...rows].sort((a, b) => b - a)
281-
const selectedShas = sorted.map(r => this.props.commitSHAs[r])
278+
const selectedShas = rows.map(r => this.props.commitSHAs[r])
282279
const selectedCommits = this.lookupCommits(selectedShas)
283-
this.props.onCommitsSelected?.(selectedCommits, this.isContiguous(sorted))
280+
this.props.onCommitsSelected?.(selectedCommits, this.isContiguous(rows))
284281
}
285282

286283
/**
@@ -294,13 +291,15 @@ export class CommitList extends React.Component<ICommitListProps, {}> {
294291
return true
295292
}
296293

297-
for (let i = 0; i < indexes.length; i++) {
298-
const current = indexes[i]
299-
if (i + 1 === indexes.length) {
294+
const sorted = [...indexes].sort((a, b) => b - a)
295+
296+
for (let i = 0; i < sorted.length; i++) {
297+
const current = sorted[i]
298+
if (i + 1 === sorted.length) {
300299
continue
301300
}
302301

303-
if (current - 1 !== indexes[i + 1]) {
302+
if (current - 1 !== sorted[i + 1]) {
304303
return false
305304
}
306305
}
@@ -374,8 +373,14 @@ export class CommitList extends React.Component<ICommitListProps, {}> {
374373
}
375374

376375
public render() {
377-
const { commitSHAs, selectedSHAs, shasToHighlight, emptyListMessage } =
378-
this.props
376+
const {
377+
commitSHAs,
378+
selectedSHAs,
379+
shasToHighlight,
380+
emptyListMessage,
381+
reorderingEnabled,
382+
isMultiCommitOperationInProgress,
383+
} = this.props
379384
if (commitSHAs.length === 0) {
380385
return (
381386
<div className="panel blankslate">
@@ -402,7 +407,10 @@ export class CommitList extends React.Component<ICommitListProps, {}> {
402407
selectionMode="multi"
403408
onScroll={this.onScroll}
404409
insertionDragType={
405-
this.props.reorderingEnabled === true ? DragType.Commit : undefined
410+
reorderingEnabled === true &&
411+
isMultiCommitOperationInProgress === false
412+
? DragType.Commit
413+
: undefined
406414
}
407415
invalidationProps={{
408416
commits: this.props.commitSHAs,

app/src/ui/history/compare.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ interface ICompareSidebarProps {
5353
readonly localTags: Map<string, string> | null
5454
readonly tagsToPush: ReadonlyArray<string> | null
5555
readonly aheadBehindStore: AheadBehindStore
56-
readonly isCherryPickInProgress: boolean
56+
readonly isMultiCommitOperationInProgress?: boolean
5757
readonly shasToHighlight: ReadonlyArray<string>
5858
}
5959

@@ -258,10 +258,12 @@ export class CompareSidebar extends React.Component<
258258
onCompareListScrolled={this.props.onCompareListScrolled}
259259
compareListScrollTop={this.props.compareListScrollTop}
260260
tagsToPush={this.props.tagsToPush ?? []}
261-
isCherryPickInProgress={this.props.isCherryPickInProgress}
262261
onRenderCommitDragElement={this.onRenderCommitDragElement}
263262
onRemoveCommitDragElement={this.onRemoveCommitDragElement}
264263
disableSquashing={formState.kind === HistoryTabMode.Compare}
264+
isMultiCommitOperationInProgress={
265+
this.props.isMultiCommitOperationInProgress
266+
}
265267
/>
266268
)
267269
}

app/src/ui/lib/list/list.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ interface IListProps {
7474
* The currently selected rows indexes. Used to attach a special
7575
* selection class on those row's containers as well as being used
7676
* for keyboard selection.
77+
*
78+
* It is expected that the use case for this is setting of the initially
79+
* selected rows or clearing a list selection.
80+
*
81+
* N.B. Since it is used for keyboard selection, changing the ordering of
82+
* elements in this array in a parent component may result in unexpected
83+
* behaviors when a user modifies their selection via key commands.
84+
* See #15536 lessons learned.
7785
*/
7886
readonly selectedRows: ReadonlyArray<number>
7987

app/src/ui/multi-commit-operation/base-multi-commit-operation.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ export abstract class BaseMultiCommitOperation extends React.Component<IMultiCom
9393
{targetBranch !== null ? <strong>{targetBranch.name}</strong> : null}
9494
</>
9595
)
96+
97+
this.props.dispatcher.closePopup(PopupType.MultiCommitOperation)
9698
return dispatcher.onConflictsFoundBanner(
9799
repository,
98100
operationDescription,

app/src/ui/repository.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import { openFile } from './lib/open-file'
3131
import { AheadBehindStore } from '../lib/stores/ahead-behind-store'
3232
import { dragAndDropManager } from '../lib/drag-and-drop-manager'
3333
import { DragType } from '../models/drag-drop'
34-
import { MultiCommitOperationKind } from '../models/multi-commit-operation'
3534
import { clamp } from '../lib/clamp'
3635

3736
interface IRepositoryViewProps {
@@ -249,10 +248,6 @@ export class RepositoryView extends React.Component<
249248
} = state
250249
const { tip } = branchesState
251250
const currentBranch = tip.kind === TipState.Valid ? tip.branch : null
252-
const isCherryPickInProgress =
253-
mcos !== null &&
254-
mcos.operationDetail.kind === MultiCommitOperationKind.CherryPick
255-
256251
const scrollTop =
257252
this.forceCompareListScrollTop ||
258253
this.previousSection === RepositorySectionTab.Changes
@@ -282,7 +277,7 @@ export class RepositoryView extends React.Component<
282277
compareListScrollTop={scrollTop}
283278
tagsToPush={tagsToPush}
284279
aheadBehindStore={aheadBehindStore}
285-
isCherryPickInProgress={isCherryPickInProgress}
280+
isMultiCommitOperationInProgress={mcos !== null}
286281
/>
287282
)
288283
}

changelog.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
{
22
"releases": {
3+
"3.1.3": [
4+
"[Fixed] Disable reorder, squashing, cherry-picking while an action of this type is in progress. - #15468",
5+
"[Fixed] Using the key command of 'Shift' + 'ArrowDown' adds the next commit below the current selection to the selection - #15549",
6+
"[Fixed] Close 'Resolve conflicts before Rebase' dialog will not disable menu items - #13081. Thanks @angusdev!",
7+
"[Fixed] Fix commit shortcut (Ctrl/Cmd + Enter) while amending a commit - #15445"
8+
],
39
"3.1.2": ["[Improved] Upgrade embedded Git to 2.35.5"],
410
"3.1.1": [
511
"[Fixed] App correctly remembers undo commit prompt setting - #15408"

0 commit comments

Comments
 (0)