Skip to content

Commit

Permalink
Merge pull request desktop#12029 from desktop/feature-flag-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiou87 authored Apr 20, 2021
2 parents 4629e4e + 7a2bf2b commit 1823807
Show file tree
Hide file tree
Showing 18 changed files with 66 additions and 269 deletions.
90 changes: 0 additions & 90 deletions app/src/lib/feature-flag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,110 +57,20 @@ export function enableDesktopTrampoline(): boolean {
return true
}

/**
* Should we show the create fork dialog flow?
*/
export function enableCreateForkFlow(): boolean {
return true
}

/**
* Whether or not to enable support for automatically resolving the
* system-configured proxy url and passing that to Git.
*/
export function enableAutomaticGitProxyConfiguration(): boolean {
return true
}

/**
* Should we show the "Create Issue on GitHub" item under
* "Repository" in the app menu?
*/
export function enableCreateGitHubIssueFromMenu(): boolean {
return true
}

/**
* Should we update remote url if it has changed?
*/
export function enableUpdateRemoteUrl(): boolean {
return true
}

/**
* Should we show the fork-specific, "branch from the upstream
* default branch" version of the create branch dialog?
*/
export function enableForkyCreateBranchUI(): boolean {
return true
}

/**
* Should we show the git tag information in the app UI?
*/
export function enableGitTagsDisplay(): boolean {
return true
}

/**
* Should we allow users to create git tags from the app?
*/
export function enableGitTagsCreation(): boolean {
return true
}

/**
* Should we show the dialogs to allow users customize which is the
* main repository when opening a fork?
*/
export function enableForkSettings(): boolean {
return true
}

/**
* Should we show the discard lines/hunks context menu item?
*/
export function enableDiscardLines(): boolean {
return true
}

/**
* Should we show the checkbox to enable side by side diffs?
*
* Note: side by side diffs will use the new diff viewer.
*/
export function enableSideBySideDiffs(): boolean {
return true
}

/**
* Should we use the new diff viewer for unified diffs?
*/
export function enableExperimentalDiffViewer(): boolean {
return false
}

/**
* Should we allow to change the default branch when creating new repositories?
*/
export function enableDefaultBranchSetting(): boolean {
return true
}

/**
* Should we allow reporting unhandled rejections as if they were crashes?
*/
export function enableUnhandledRejectionReporting(): boolean {
return enableBetaFeatures()
}

/**
* Should we allow cherry picking
*/
export function enableCherryPicking(): boolean {
return true
}

/** Should we allow expanding text diffs? */
export function enableTextDiffExpansion(): boolean {
return enableBetaFeatures()
Expand Down
5 changes: 0 additions & 5 deletions app/src/lib/git/environment.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { envForAuthentication } from './authentication'
import { IGitAccount } from '../../models/git-account'
import { enableAutomaticGitProxyConfiguration } from '../feature-flag'
import { resolveGitProxy } from '../resolve-git-proxy'
import { getDotComAPIEndpoint } from '../api'
import { Repository } from '../../models/repository'
Expand Down Expand Up @@ -87,10 +86,6 @@ export async function envForProxy(
env: NodeJS.ProcessEnv = process.env,
resolve: (url: string) => Promise<string | undefined> = resolveGitProxy
): Promise<NodeJS.ProcessEnv | undefined> {
if (!enableAutomaticGitProxyConfiguration()) {
return
}

const protocolMatch = /^(https?):\/\//i.exec(remoteUrl)

// We can only resolve and use a proxy for the protocols where cURL
Expand Down
5 changes: 0 additions & 5 deletions app/src/lib/helpers/default-branch.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { getGlobalConfigValue, setGlobalConfigValue } from '../git'
import { enableDefaultBranchSetting } from '../feature-flag'

/**
* The default branch name that GitHub Desktop will use when
Expand All @@ -23,10 +22,6 @@ export const SuggestedBranchNames: ReadonlyArray<string> = ['main', 'master']
* Returns the configured default branch when creating new repositories
*/
async function getConfiguredDefaultBranch(): Promise<string | null> {
if (!enableDefaultBranchSetting()) {
return null
}

return getGlobalConfigValue(DefaultBranchSettingName)
}

Expand Down
5 changes: 0 additions & 5 deletions app/src/lib/resolve-git-proxy.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import { remote } from 'electron'
import { enableAutomaticGitProxyConfiguration } from './feature-flag'
import { parsePACString } from './parse-pac-string'

export async function resolveGitProxy(
url: string
): Promise<string | undefined> {
if (!enableAutomaticGitProxyConfiguration()) {
return undefined
}

// resolveProxy doesn't throw an error (at least not in the
// current Electron version) but it could in the future and
// it's also possible that the IPC layer could throw an
Expand Down
7 changes: 2 additions & 5 deletions app/src/lib/stores/app-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,7 @@ import {
} from './updates/changes-state'
import { ManualConflictResolution } from '../../models/manual-conflict-resolution'
import { BranchPruner } from './helpers/branch-pruner'
import {
enableHideWhitespaceInDiffOption,
enableUpdateRemoteUrl,
} from '../feature-flag'
import { enableHideWhitespaceInDiffOption } from '../feature-flag'
import { Banner, BannerType } from '../../models/banner'
import moment from 'moment'
import { ComputedAction } from '../../models/computed-action'
Expand Down Expand Up @@ -3354,7 +3351,7 @@ export class AppStore extends TypedBaseStore<IAppState> {
return repository
}

if (enableUpdateRemoteUrl() && repository.gitHubRepository) {
if (repository.gitHubRepository) {
const gitStore = this.gitStoreCache.get(repository)
await updateRemoteUrl(gitStore, repository.gitHubRepository, apiRepo)
}
Expand Down
2 changes: 0 additions & 2 deletions app/src/main-process/menu/build-default-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { truncateWithEllipsis } from '../../lib/truncate-with-ellipsis'
import { getLogDirectoryPath } from '../../lib/logging/get-log-path'
import { ensureDir } from 'fs-extra'
import { UNSAFE_openDirectory } from '../shell'
import { enableCreateGitHubIssueFromMenu } from '../../lib/feature-flag'
import { MenuLabelsEvent } from '../../models/menu-labels'

const platformDefaultShell = __WIN32__ ? 'Command Prompt' : 'Terminal'
Expand Down Expand Up @@ -328,7 +327,6 @@ export function buildDefaultMenu({
: 'Create &issue on GitHub',
accelerator: 'CmdOrCtrl+I',
click: emit('create-issue-in-repository-on-github'),
visible: enableCreateGitHubIssueFromMenu(),
},
separator,
{
Expand Down
6 changes: 1 addition & 5 deletions app/src/ui/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ import { StashAndSwitchBranch } from './stash-changes/stash-and-switch-branch-di
import { OverwriteStash } from './stash-changes/overwrite-stashed-changes-dialog'
import { ConfirmDiscardStashDialog } from './stashing/confirm-discard-stash'
import { CreateTutorialRepositoryDialog } from './no-repositories/create-tutorial-repository-dialog'
import { enableForkyCreateBranchUI } from '../lib/feature-flag'
import { ConfirmExitTutorial } from './tutorial'
import { TutorialStep, isValidTutorialStep } from '../models/tutorial-step'
import { WorkflowPushRejectedDialog } from './workflow-push-rejected/workflow-push-rejected'
Expand Down Expand Up @@ -1505,10 +1504,7 @@ export class App extends React.Component<IAppProps, IAppState> {
let upstreamGhRepo: GitHubRepository | null = null
let upstreamDefaultBranch: Branch | null = null

if (
enableForkyCreateBranchUI() &&
isRepositoryWithGitHubRepository(repository)
) {
if (isRepositoryWithGitHubRepository(repository)) {
upstreamGhRepo = getNonForkGitHubRepository(repository)
upstreamDefaultBranch = findDefaultUpstreamBranch(
repository,
Expand Down
23 changes: 10 additions & 13 deletions app/src/ui/changes/changed-file-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { AppFileStatus } from '../../models/status'
import { IDiff, DiffType } from '../../models/diff'
import { Octicon, OcticonSymbol, iconForStatus } from '../octicons'
import { mapStatus } from '../../lib/status'
import { enableSideBySideDiffs } from '../../lib/feature-flag'
import { DiffOptions } from '../diff/diff-options'
import { RepositorySectionTab } from '../../lib/app-state'

Expand Down Expand Up @@ -43,18 +42,16 @@ export class ChangedFileDetails extends React.Component<
<PathLabel path={this.props.path} status={this.props.status} />
{this.renderDecorator()}

{enableSideBySideDiffs() && (
<DiffOptions
sourceTab={RepositorySectionTab.Changes}
onHideWhitespaceChangesChanged={
this.props.onHideWhitespaceInDiffChanged
}
hideWhitespaceChanges={this.props.hideWhitespaceInDiff}
onShowSideBySideDiffChanged={this.props.onShowSideBySideDiffChanged}
showSideBySideDiff={this.props.showSideBySideDiff}
onDiffOptionsOpened={this.props.onDiffOptionsOpened}
/>
)}
<DiffOptions
sourceTab={RepositorySectionTab.Changes}
onHideWhitespaceChangesChanged={
this.props.onHideWhitespaceInDiffChanged
}
hideWhitespaceChanges={this.props.hideWhitespaceInDiff}
onShowSideBySideDiffChanged={this.props.onShowSideBySideDiffChanged}
showSideBySideDiff={this.props.showSideBySideDiff}
onDiffOptionsOpened={this.props.onDiffOptionsOpened}
/>

<Octicon
symbol={iconForStatus(status)}
Expand Down
6 changes: 1 addition & 5 deletions app/src/ui/diff/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import { SideBySideDiff } from './side-by-side-diff'
import {
enableHideWhitespaceInDiffOption,
enableExperimentalDiffViewer,
enableSideBySideDiffs,
} from '../../lib/feature-flag'

// image used when no diff is displayed
Expand Down Expand Up @@ -247,10 +246,7 @@ export class Diff extends React.Component<IDiffProps, IDiffState> {
}

private renderTextDiff(diff: ITextDiff) {
if (
enableExperimentalDiffViewer() ||
(enableSideBySideDiffs() && this.props.showSideBySideDiff)
) {
if (enableExperimentalDiffViewer() || this.props.showSideBySideDiff) {
return (
<SideBySideDiff
repository={this.props.repository}
Expand Down
9 changes: 1 addition & 8 deletions app/src/ui/diff/text-diff.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ import { clamp } from '../../lib/clamp'
import { uuid } from '../../lib/uuid'
import { showContextualMenu } from '../main-process-proxy'
import { IMenuItem } from '../../lib/menu-item'
import {
enableDiscardLines,
enableTextDiffExpansion,
} from '../../lib/feature-flag'
import { enableTextDiffExpansion } from '../../lib/feature-flag'
import { canSelect } from './diff-helpers'
import {
expandTextDiffHunk,
Expand Down Expand Up @@ -706,10 +703,6 @@ export class TextDiff extends React.Component<ITextDiffProps, ITextDiffState> {
editor: CodeMirror.Editor,
event: Event
): ReadonlyArray<IMenuItem> | null {
if (!enableDiscardLines()) {
return null
}

const file = this.props.file

if (this.props.readOnly || !canSelect(file)) {
Expand Down
6 changes: 1 addition & 5 deletions app/src/ui/dispatcher/dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ import { UncommittedChangesStrategy } from '../../models/uncommitted-changes-str
import { RebaseFlowStep, RebaseStep } from '../../models/rebase-flow-step'
import { IStashEntry } from '../../models/stash-entry'
import { WorkflowPreferences } from '../../models/workflow-preferences'
import { enableForkSettings } from '../../lib/feature-flag'
import { resolveWithin } from '../../lib/path'
import {
CherryPickFlowStep,
Expand Down Expand Up @@ -681,10 +680,7 @@ export class Dispatcher {
const addedRepository = addedRepositories[0]
await this.selectRepository(addedRepository)

if (
enableForkSettings() &&
isRepositoryWithForkedGitHubRepository(addedRepository)
) {
if (isRepositoryWithForkedGitHubRepository(addedRepository)) {
this.showPopup({
type: PopupType.ChooseForkSettings,
repository: addedRepository,
Expand Down
7 changes: 0 additions & 7 deletions app/src/ui/dispatcher/error-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
} from '../../models/repository'
import { getDotComAPIEndpoint } from '../../lib/api'
import { hasWritePermission } from '../../models/github-repository'
import { enableCreateForkFlow } from '../../lib/feature-flag'
import { RetryActionType } from '../../models/retry-actions'
import { parseFilesToBeOverwritten } from '../lib/parse-files-to-be-overwritten'

Expand Down Expand Up @@ -533,12 +532,6 @@ export async function insufficientGitHubRepoPermissions(
error: Error,
dispatcher: Dispatcher
) {
// no need to do anything here if we don't want to show
// the new `CreateForkDialog` UI
if (!enableCreateForkFlow()) {
return error
}

const e = asErrorWithMetadata(error)
if (!e) {
return error
Expand Down
6 changes: 1 addition & 5 deletions app/src/ui/forks/create-fork-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { Account } from '../../models/account'
import { API } from '../../lib/api'
import { LinkButton } from '../lib/link-button'
import { PopupType } from '../../models/popup'
import { enableForkSettings } from '../../lib/feature-flag'

interface ICreateForkDialogProps {
readonly dispatcher: Dispatcher
Expand Down Expand Up @@ -61,10 +60,7 @@ export class CreateForkDialog extends React.Component<
this.setState({ loading: false })
this.props.onDismissed()

if (
enableForkSettings() &&
isRepositoryWithForkedGitHubRepository(updatedRepository)
) {
if (isRepositoryWithForkedGitHubRepository(updatedRepository)) {
this.props.dispatcher.showPopup({
type: PopupType.ChooseForkSettings,
repository: updatedRepository,
Expand Down
Loading

0 comments on commit 1823807

Please sign in to comment.