Skip to content

Commit

Permalink
Merge branch 'development' into windows-arm-support
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiou87 committed Apr 6, 2021
2 parents 0c3f4c8 + 58067b8 commit cdbbd80
Show file tree
Hide file tree
Showing 133 changed files with 6,816 additions and 1,043 deletions.
6 changes: 3 additions & 3 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"productName": "GitHub Desktop",
"bundleID": "com.github.GitHubClient",
"companyName": "GitHub, Inc.",
"version": "2.6.4-beta2",
"version": "2.7.2-beta2",
"main": "./main.js",
"repository": {
"type": "git",
Expand All @@ -25,10 +25,10 @@
"codemirror-mode-elixir": "^1.1.2",
"compare-versions": "^3.6.0",
"deep-equal": "^1.0.1",
"desktop-trampoline": "desktop/desktop-trampoline#v0.9.3",
"desktop-trampoline": "desktop/desktop-trampoline#v0.9.4",
"dexie": "^2.0.0",
"double-ended-queue": "^2.1.0-0",
"dugite": "^1.98.0",
"dugite": "^1.102.0",
"electron-window-state": "^5.0.3",
"event-kit": "^2.0.0",
"file-metadata": "^1.0.0",
Expand Down
11 changes: 11 additions & 0 deletions app/src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ import username from 'username'
import { GitProtocol } from './remote-parsing'

const envEndpoint = process.env['DESKTOP_GITHUB_DOTCOM_API_ENDPOINT']
const envHTMLURL = process.env['DESKTOP_GITHUB_DOTCOM_HTML_URL']
const envAdditionalCookies =
process.env['DESKTOP_GITHUB_DOTCOM_ADDITIONAL_COOKIES']

if (envAdditionalCookies !== undefined) {
document.cookie += '; ' + envAdditionalCookies
}

/**
* Optional set of configurable settings for the fetchAll method
Expand Down Expand Up @@ -1325,6 +1332,10 @@ export function getEndpointForRepository(url: string): string {
* http://github.mycompany.com/api -> http://github.mycompany.com/
*/
export function getHTMLURL(endpoint: string): string {
if (envHTMLURL !== undefined) {
return envHTMLURL
}

// In the case of GitHub.com, the HTML site lives on the parent domain.
// E.g., https://api.github.com -> https://github.com
//
Expand Down
97 changes: 89 additions & 8 deletions app/src/lib/app-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
Progress,
ICheckoutProgress,
ICloneProgress,
ICherryPickProgress,
} from '../models/progress'
import { Popup } from '../models/popup'

Expand All @@ -28,7 +29,7 @@ import { SignInState } from './stores/sign-in-store'
import { WindowState } from './window-state'
import { Shell } from './shells'

import { ApplicationTheme } from '../ui/lib/application-theme'
import { ApplicableTheme, ApplicationTheme } from '../ui/lib/application-theme'
import { IAccountRepositories } from './stores/api-repositories-store'
import { ManualConflictResolution } from '../models/manual-conflict-resolution'
import { Banner } from '../models/banner'
Expand All @@ -37,6 +38,8 @@ import { RebaseFlowStep } from '../models/rebase-flow-step'
import { IStashEntry } from '../models/stash-entry'
import { TutorialStep } from '../models/tutorial-step'
import { UncommittedChangesStrategy } from '../models/uncommitted-changes-strategy'
import { CherryPickFlowStep } from '../models/cherry-pick'
import { DragElement } from '../models/drag-element'

export enum SelectionType {
Repository,
Expand Down Expand Up @@ -109,6 +112,12 @@ export interface IAppState {
readonly currentFoldout: Foldout | null
readonly currentBanner: Banner | null

/**
* The shape of the drag element rendered in the `app.renderDragElement`. It
* is used in conjunction with the `Draggable` component.
*/
readonly currentDragElement: DragElement | null

/**
* A list of currently open menus with their selected items
* in the application menu.
Expand Down Expand Up @@ -211,11 +220,11 @@ export interface IAppState {
/** The currently selected tab for the Branches foldout. */
readonly selectedBranchesTab: BranchesTab

/** The currently selected appearance (aka theme) */
/** The selected appearance (aka theme) preference */
readonly selectedTheme: ApplicationTheme

/** Whether we should automatically change the currently selected appearance (aka theme) */
readonly automaticallySwitchTheme: boolean
/** The currently applied appearance (aka theme) */
readonly currentTheme: ApplicableTheme

/**
* A map keyed on a user account (GitHub.com or GitHub Enterprise)
Expand Down Expand Up @@ -249,6 +258,11 @@ export interface IAppState {
* Whether or not the app should use spell check on commit summary and description
*/
readonly commitSpellcheckEnabled: boolean

/**
* Whether or not the user has been introduced to the cherry pick feature
*/
readonly hasShownCherryPickIntro: boolean
}

export enum FoldoutType {
Expand Down Expand Up @@ -351,13 +365,16 @@ export function isRebaseConflictState(
}

/**
* Conflicts can occur during a rebase or a merge.
* Conflicts can occur during a rebase, merge, or cherry pick.
*
* Callers should inspect the `kind` field to determine the kind of conflict
* that is occurring, as this will then provide additional information specific
* to the conflict, to help with resolving the issue.
*/
export type ConflictState = MergeConflictState | RebaseConflictState
export type ConflictState =
| MergeConflictState
| RebaseConflictState
| CherryPickConflictState

export interface IRepositoryState {
readonly commitSelection: ICommitSelection
Expand Down Expand Up @@ -430,6 +447,9 @@ export interface IRepositoryState {
readonly revertProgress: IRevertProgress | null

readonly localTags: Map<string, string> | null

/** State associated with a cherry pick being performed */
readonly cherryPickState: ICherryPickState
}

export interface IBranchesState {
Expand Down Expand Up @@ -522,8 +542,8 @@ export interface IRebaseState {
}

export interface ICommitSelection {
/** The commit currently selected in the app */
readonly sha: string | null
/** The commits currently selected in the app */
readonly shas: ReadonlyArray<string>

/** The list of files associated with the current commit */
readonly changedFiles: ReadonlyArray<CommittedFileChange>
Expand Down Expand Up @@ -724,3 +744,64 @@ export interface ICompareToBranch {
* An action to send to the application store to update the compare state
*/
export type CompareAction = IViewHistory | ICompareToBranch

/** State associated with a cherry pick being performed on a repository */
export interface ICherryPickState {
/**
* The current step of the flow the user should see.
*
* `null` indicates that there is no cherry pick underway.
*/
readonly step: CherryPickFlowStep | null

/**
* The underlying Git information associated with the current cherry pick
*
* This will be set to `null` when no target branch has been selected to
* initiate the rebase.
*/
readonly progress: ICherryPickProgress | null

/**
* Whether the user has done work to resolve any conflicts as part of this
* cherry pick.
*/
readonly userHasResolvedConflicts: boolean

/**
* The sha of the target branch tip before cherry pick initiated.
*
* This will be set to null if no cherry pick has been initiated.
*/
readonly targetBranchUndoSha: string | null

/**
* Whether the target branch was created during cherry-pick operation
*/
readonly branchCreated: boolean
}

/**
* Stores information about a cherry pick conflict when it occurs
*/
export type CherryPickConflictState = {
readonly kind: 'cherryPick'

/**
* Manual resolutions chosen by the user for conflicted files to be applied
* before continuing the cherry pick.
*/
readonly manualResolutions: Map<string, ManualConflictResolution>

/**
* The branch chosen by the user to copy the cherry picked commits to
*/
readonly targetBranchName: string
}

/** Guard function for checking conflicts are from a rebase */
export function isCherryPickConflictState(
conflictStatus: ConflictState
): conflictStatus is CherryPickConflictState {
return conflictStatus.kind === 'cherryPick'
}
7 changes: 6 additions & 1 deletion app/src/lib/diff-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,15 +288,17 @@ export class DiffParser {

const header = this.parseHunkHeader(headerLine)
const lines = new Array<DiffLine>()
lines.push(new DiffLine(headerLine, DiffLineType.Hunk, null, null))
lines.push(new DiffLine(headerLine, DiffLineType.Hunk, 1, null, null))

let c: DiffLinePrefix | null

let rollingDiffBeforeCounter = header.oldStartLine
let rollingDiffAfterCounter = header.newStartLine

let diffLineNumber = linesConsumed
while ((c = this.parseLinePrefix(this.peek()))) {
const line = this.readLine()
diffLineNumber++

if (!line) {
throw new Error('Expected unified diff line but reached end of diff')
Expand Down Expand Up @@ -329,20 +331,23 @@ export class DiffParser {
diffLine = new DiffLine(
line,
DiffLineType.Add,
diffLineNumber,
null,
rollingDiffAfterCounter++
)
} else if (c === DiffPrefixDelete) {
diffLine = new DiffLine(
line,
DiffLineType.Delete,
diffLineNumber,
rollingDiffBeforeCounter++,
null
)
} else if (c === DiffPrefixContext) {
diffLine = new DiffLine(
line,
DiffLineType.Context,
diffLineNumber,
rollingDiffBeforeCounter++,
rollingDiffAfterCounter++
)
Expand Down
57 changes: 57 additions & 0 deletions app/src/lib/drag-and-drop-manager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { Disposable, Emitter } from 'event-kit'

/**
* The drag and drop manager is implemented to manage drag and drop events
* that we want to track app wide without updating the enter app state.
*
* This was specifically implemented due to reduced performance during drag and
* drop when updating app state variables to track drag element changes during a
* drag event.
*/
export class DragAndDropManager {
private _isDragInProgress: boolean = false

protected readonly emitter = new Emitter()

public get isDragInProgress(): boolean {
return this._isDragInProgress
}

public emitEnterDropTarget(targetDescription: string) {
this.emitter.emit('enter-drop-target', targetDescription)
}

public emitLeaveDropTarget() {
this.emitter.emit('leave-drop-target', {})
}

public onEnterDropTarget(
fn: (targetDescription: string) => void
): Disposable {
return this.emitter.on('enter-drop-target', fn)
}

public onLeaveDropTarget(fn: () => void): Disposable {
return this.emitter.on('leave-drop-target', fn)
}

public dragStarted(): void {
this._isDragInProgress = true
}

public dragEnded() {
this._isDragInProgress = false
}

public emitEnterDragZone(dropZoneDescription: string) {
this.emitter.emit('enter-drop-zone', dropZoneDescription)
}

public onEnterDragZone(
fn: (dropZoneDescription: string) => void
): Disposable {
return this.emitter.on('enter-drop-zone', fn)
}
}

export const dragAndDropManager = new DragAndDropManager()
4 changes: 4 additions & 0 deletions app/src/lib/editors/darwin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ const editors: IDarwinExternalEditor[] = [
name: 'RubyMine',
bundleIdentifiers: ['com.jetbrains.RubyMine'],
},
{
name: 'RStudio',
bundleIdentifiers: ['org.rstudio.RStudio'],
},
{
name: 'TextMate',
bundleIdentifiers: ['com.macromates.TextMate'],
Expand Down
8 changes: 8 additions & 0 deletions app/src/lib/editors/win32.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,14 @@ const editors: IWindowsExternalEditor[] = [
displayName.startsWith('JetBrains Rider') &&
publisher === 'JetBrains s.r.o.',
},
{
name: 'RStudio',
registryKeys: [Wow64LocalMachineUninstallKey('RStudio')],
executableShimPath: [],
installLocationRegistryKey: 'DisplayIcon',
expectedInstallationChecker: (displayName, publisher) =>
displayName === 'RStudio' && publisher === 'RStudio',
},
]

function getKeyOrEmpty(
Expand Down
14 changes: 12 additions & 2 deletions app/src/lib/feature-flag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,14 @@ export function enableWSLDetection(): boolean {
return enableBetaFeatures()
}

/** Should the app show hide whitespace in changes tab */
export function enableHideWhitespaceInDiffOption(): boolean {
return enableDevelopmentFeatures()
}

/** Should the app use the shiny new TCP-based trampoline? */
export function enableDesktopTrampoline(): boolean {
return enableBetaFeatures()
return true
}

/**
Expand Down Expand Up @@ -153,5 +158,10 @@ export function enableUnhandledRejectionReporting(): boolean {
* Should we allow cherry picking
*/
export function enableCherryPicking(): boolean {
return false // enableBetaFeatures()
return true
}

/** Should we allow expanding text diffs? */
export function enableTextDiffExpansion(): boolean {
return enableDevelopmentFeatures()
}

0 comments on commit cdbbd80

Please sign in to comment.