Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/development'
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieudutour committed Apr 1, 2020
2 parents 3a64a3b + 378fd74 commit 2598ec2
Show file tree
Hide file tree
Showing 150 changed files with 7,535 additions and 5,110 deletions.
2 changes: 1 addition & 1 deletion app/.npmrc
@@ -1,4 +1,4 @@
runtime = electron
disturl = https://atom.io/download/electron
target = 5.0.6
target = 7.1.8
arch = x64
380 changes: 317 additions & 63 deletions app/package-lock.json

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions app/package.json
Expand Up @@ -3,7 +3,7 @@
"productName": "Kactus",
"bundleID": "io.kactus.KactusClient",
"companyName": "Kactus.io",
"version": "0.3.26",
"version": "0.3.27",
"main": "./main.js",
"repository": {
"type": "git",
Expand All @@ -23,19 +23,20 @@
"classnames": "^2.2.5",
"codemirror": "^5.49.2",
"codemirror-mode-elixir": "^1.1.2",
"compare-versions": "^3.6.0",
"deep-equal": "^1.0.1",
"dexie": "^2.0.0",
"double-ended-queue": "^2.1.0-0",
"dugite": "1.88.0",
"dugite": "1.88.2",
"electron-window-state": "^5.0.3",
"event-kit": "^2.0.0",
"file-uri-to-path": "0.0.2",
"file-url": "^2.0.2",
"fs-admin": "^0.3.1",
"fs-extra": "^6.0.0",
"fs-admin": "^0.12.0",
"fs-extra": "^7.0.1",
"fuzzaldrin-plus": "^0.6.0",
"kactus-cli": "^0.6.1",
"keytar": "^4.4.1",
"keytar": "^5.0.0",
"mem": "^4.3.0",
"memoize-one": "^4.0.3",
"moment": "^2.24.0",
Expand Down Expand Up @@ -69,7 +70,7 @@
},
"devDependencies": {
"devtron": "^1.4.0",
"electron-debug": "^2.0.0",
"electron-debug": "^3.0.1",
"electron-devtools-installer": "^2.2.4",
"temp": "^0.8.3",
"webpack-hot-middleware": "^2.10.0"
Expand Down
2 changes: 1 addition & 1 deletion app/src/crash/crash-app.tsx
Expand Up @@ -104,7 +104,7 @@ export class CrashApp extends React.Component<ICrashAppProps, ICrashAppState> {

ipcRenderer.on(
'error',
(event: Electron.IpcMessageEvent, crashDetails: ICrashDetails) => {
(event: Electron.IpcRendererEvent, crashDetails: ICrashDetails) => {
this.setState(crashDetails)
}
)
Expand Down
40 changes: 39 additions & 1 deletion app/src/lib/api.ts
Expand Up @@ -108,6 +108,8 @@ export interface IAPIRepository {
readonly fork: boolean
readonly default_branch: string
readonly pushed_at: string
readonly has_issues: boolean
readonly archived: boolean
readonly parent?: IAPIRepository

/**
Expand Down Expand Up @@ -705,6 +707,26 @@ export class API {
}
}

/** Create a new GitHub fork of this repository (owner and name) */
public async forkRepository(
owner: string,
name: string
): Promise<IAPIRepository> {
try {
const apiPath = `/repos/${owner}/${name}/forks`
const response = await this.request('POST', apiPath)
return await parsedResponse<IAPIRepository>(response)
} catch (e) {
log.error(
`forkRepository: failed to fork ${owner}/${name} at endpoint: ${
this.endpoint
}`,
e
)
throw e
}
}

/**
* Fetch the issues with the given state that have been created or updated
* since the given date.
Expand Down Expand Up @@ -816,6 +838,20 @@ export class API {
}
}

/**
* Fetch a single pull request in the given repository
*/
public async fetchPullRequest(owner: string, name: string, prNumber: string) {
try {
const path = `/repos/${owner}/${name}/pulls/${prNumber}`
const response = await this.request('GET', path)
return await parsedResponse<IAPIPullRequest>(response)
} catch (e) {
log.warn(`failed fetching PR for ${owner}/${name}/pulls/${prNumber}`, e)
throw e
}
}

/**
* Get the combined status for the given ref.
*
Expand All @@ -842,7 +878,9 @@ export class API {
name: string,
branch: string
): Promise<IAPIPushControl> {
const path = `repos/${owner}/${name}/branches/${branch}/push_control`
const path = `repos/${owner}/${name}/branches/${encodeURIComponent(
branch
)}/push_control`

const headers: any = {
Accept: 'application/vnd.github.phandalin-preview',
Expand Down
6 changes: 1 addition & 5 deletions app/src/lib/app-shell.ts
Expand Up @@ -16,13 +16,9 @@ export const shell: IAppShell = {
beep: electronShell.beep,
openExternal: path => {
return new Promise<boolean>((resolve, reject) => {
type OpenExternalResultArg = { result: boolean }
ipcRenderer.once(
'open-external-result',
(
event: Electron.IpcMessageEvent,
{ result }: OpenExternalResultArg
) => {
(event: Electron.IpcRendererEvent, { result }: { result: boolean }) => {
resolve(result)
}
)
Expand Down
25 changes: 25 additions & 0 deletions app/src/lib/branch.ts
@@ -0,0 +1,25 @@
import { Branch, BranchType } from '../models/branch'
import { UpstreamRemoteName } from './stores'

/**
* Finds the remote branch for a branch in the upstream repository
*
* For example:
* If official/funnel has the branch `development`, then running
* this on the branches from the fork outofambit/funnel with
* `development` as the specified branch name will find the
* branch `remotes/upstream/development`
*
* @param branchName short name of the branch in the upstream repo
* @param branches all the branches in the local repo
*/
export function findUpstreamRemoteBranch(
branchName: string,
branches: ReadonlyArray<Branch>
) {
return branches.find(
b =>
b.type === BranchType.Remote &&
b.name === `${UpstreamRemoteName}/${branchName}`
)
}
14 changes: 12 additions & 2 deletions app/src/lib/create-branch.ts
Expand Up @@ -4,6 +4,7 @@ import { StartPoint, Branch } from '../models/branch'
type BranchInfo = {
readonly tip: Tip
readonly defaultBranch: Branch | null
readonly upstreamDefaultBranch: Branch | null
}

export function getStartPoint(
Expand All @@ -14,7 +15,14 @@ export function getStartPoint(
return StartPoint.Head
}

if (preferred === StartPoint.DefaultBranch && props.defaultBranch) {
if (
preferred === StartPoint.UpstreamDefaultBranch &&
props.upstreamDefaultBranch !== null
) {
return preferred
}

if (preferred === StartPoint.DefaultBranch && props.defaultBranch !== null) {
return preferred
}

Expand All @@ -29,7 +37,9 @@ export function getStartPoint(
return preferred
}

if (props.defaultBranch) {
if (props.upstreamDefaultBranch) {
return StartPoint.UpstreamDefaultBranch
} else if (props.defaultBranch) {
return StartPoint.DefaultBranch
} else if (props.tip.kind === TipState.Valid) {
return StartPoint.CurrentBranch
Expand Down
3 changes: 3 additions & 0 deletions app/src/lib/databases/repositories-database.ts
Expand Up @@ -22,6 +22,9 @@ export interface IDatabaseGitHubRepository {
/** The last time a prune was attempted on the repository */
readonly lastPruneDate: number | null

readonly issuesEnabled?: boolean
readonly isArchived?: boolean

readonly permissions?: 'read' | 'write' | 'admin' | null
}

Expand Down
31 changes: 31 additions & 0 deletions app/src/lib/editors/utils.ts
Expand Up @@ -19,8 +19,10 @@ export enum ExternalEditor {
Typora = 'Typora',
CodeRunner = 'CodeRunner',
SlickEdit = 'SlickEdit',
IntelliJ = 'IntelliJ',
Xcode = 'Xcode',
GoLand = 'GoLand',
AndroidStudio = 'Android Studio',
}

export function parse(label: string): ExternalEditor | null {
Expand Down Expand Up @@ -71,12 +73,18 @@ export function parse(label: string): ExternalEditor | null {
if (label === ExternalEditor.SlickEdit) {
return ExternalEditor.SlickEdit
}
if (label === ExternalEditor.IntelliJ) {
return ExternalEditor.IntelliJ
}
if (label === ExternalEditor.Xcode) {
return ExternalEditor.Xcode
}
if (label === ExternalEditor.GoLand) {
return ExternalEditor.GoLand
}
if (label === ExternalEditor.AndroidStudio) {
return ExternalEditor.AndroidStudio
}
return null
}

Expand Down Expand Up @@ -105,6 +113,8 @@ function getBundleIdentifiers(editor: ExternalEditor): ReadonlyArray<string> {
return ['com.jetbrains.PhpStorm']
case ExternalEditor.RubyMine:
return ['com.jetbrains.RubyMine']
case ExternalEditor.IntelliJ:
return ['com.jetbrains.intellij']
case ExternalEditor.TextMate:
return ['com.macromates.TextMate']
case ExternalEditor.Brackets:
Expand All @@ -126,6 +136,8 @@ function getBundleIdentifiers(editor: ExternalEditor): ReadonlyArray<string> {
return ['com.apple.dt.Xcode']
case ExternalEditor.GoLand:
return ['com.jetbrains.goland']
case ExternalEditor.AndroidStudio:
return ['com.google.android.studio']
default:
return assertNever(editor, `Unknown external editor: ${editor}`)
}
Expand Down Expand Up @@ -173,6 +185,8 @@ function getExecutableShim(
return Path.join(installPath, 'Contents', 'MacOS', 'Brackets')
case ExternalEditor.WebStorm:
return Path.join(installPath, 'Contents', 'MacOS', 'WebStorm')
case ExternalEditor.IntelliJ:
return Path.join(installPath, 'Contents', 'MacOS', 'idea')
case ExternalEditor.Typora:
return Path.join(installPath, 'Contents', 'MacOS', 'Typora')
case ExternalEditor.CodeRunner:
Expand All @@ -183,6 +197,8 @@ function getExecutableShim(
return '/usr/bin/xed'
case ExternalEditor.GoLand:
return Path.join(installPath, 'Contents', 'MacOS', 'goland')
case ExternalEditor.AndroidStudio:
return Path.join(installPath, 'Contents', 'MacOS', 'studio')
default:
return assertNever(editor, `Unknown external editor: ${editor}`)
}
Expand Down Expand Up @@ -233,8 +249,10 @@ export async function getAvailableEditors(): Promise<
typoraPath,
codeRunnerPath,
slickeditPath,
intellijPath,
xcodePath,
golandPath,
androidStudioPath,
] = await Promise.all([
findApplication(ExternalEditor.Atom),
findApplication(ExternalEditor.MacVim),
Expand All @@ -251,8 +269,10 @@ export async function getAvailableEditors(): Promise<
findApplication(ExternalEditor.Typora),
findApplication(ExternalEditor.CodeRunner),
findApplication(ExternalEditor.SlickEdit),
findApplication(ExternalEditor.IntelliJ),
findApplication(ExternalEditor.Xcode),
findApplication(ExternalEditor.GoLand),
findApplication(ExternalEditor.AndroidStudio),
])

if (atomPath) {
Expand Down Expand Up @@ -318,6 +338,10 @@ export async function getAvailableEditors(): Promise<
results.push({ editor: ExternalEditor.SlickEdit, path: slickeditPath })
}

if (intellijPath) {
results.push({ editor: ExternalEditor.IntelliJ, path: intellijPath })
}

if (xcodePath) {
results.push({ editor: ExternalEditor.Xcode, path: xcodePath })
}
Expand All @@ -326,6 +350,13 @@ export async function getAvailableEditors(): Promise<
results.push({ editor: ExternalEditor.GoLand, path: golandPath })
}

if (androidStudioPath) {
results.push({
editor: ExternalEditor.AndroidStudio,
path: androidStudioPath,
})
}

return results
}

Expand Down
43 changes: 38 additions & 5 deletions app/src/lib/feature-flag.ts
Expand Up @@ -27,11 +27,6 @@ function enableBetaFeatures(): boolean {
return enableDevelopmentFeatures() || __RELEASE_CHANNEL__ === 'beta'
}

/** Should merge tool integration be enabled? */
export function enableMergeTool(): boolean {
return enableDevelopmentFeatures()
}

/** Should git pass `--recurse-submodules` when performing operations? */
export function enableRecurseSubmodulesFlag(): boolean {
return enableBetaFeatures()
Expand Down Expand Up @@ -113,3 +108,41 @@ export function enableHideWhitespaceInDiffOption(): boolean {
export function enableTutorial(): 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
}
16 changes: 16 additions & 0 deletions app/src/lib/friendly-endpoint-name.ts
@@ -0,0 +1,16 @@
import * as URL from 'url'
import { Account } from '../models/account'
import { getDotComAPIEndpoint } from './api'

/**
* Generate a human-friendly description of the Account endpoint.
*
* Accounts on GitHub.com will return the string 'GitHub.com'
* whereas GitHub Enterprise Server accounts will return the
* hostname without the protocol and/or path.
*/
export function friendlyEndpointName(account: Account) {
return account.endpoint === getDotComAPIEndpoint()
? 'GitHub.com'
: URL.parse(account.endpoint).hostname || account.endpoint
}

0 comments on commit 2598ec2

Please sign in to comment.