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 Dec 2, 2020
2 parents a66d7b9 + 4f0d56b commit 51beb8a
Show file tree
Hide file tree
Showing 103 changed files with 2,149 additions and 3,576 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
---
name: "\U00002B50 Submit a request or solve a problem"
about: Surface a problem that you think should be solved
name: "⭐ Submit a feature request"
about: 'Feature requests are considered based on team''s capacity '
title: ''
labels: ''
assignees: ''

---

### Describe the feature or problem you’d like to solve

A clear and concise description of what the feature or problem is.
A clear and concise description of what the feature or problem is. If this is a bug report, please use the bug report template instead.

### Proposed solution

Expand Down
3 changes: 3 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
---
name: 🐛 Bug report
about: Report a problem encountered while using Kactus
title: ''
labels: ''
assignees: ''

---

Expand Down
5 changes: 2 additions & 3 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"recommendations": [
"ms-vscode.vscode-typescript-tslint-plugin",
"msjsdiag.debugger-for-chrome",
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint"
"dbaeumer.vscode-eslint",
"stkb.rewrap"
]
}
12 changes: 11 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"**/dist": true,
"**/node_modules": true,
"**/out": true,
"app/test/fixtures": true
"app/test/fixtures": true,
"vendor": true
},
"files.exclude": {
"**/.git": true,
Expand All @@ -19,6 +20,7 @@
".awcache": true,
".eslintcache": true
},
"files.insertFinalNewline": true,
"editor.tabSize": 2,
"prettier.semi": false,
"prettier.singleQuote": true,
Expand All @@ -35,5 +37,13 @@
"javascriptreact",
"typescript",
"typescriptreact"
],
"spellright.language": [
"en"
],
"spellright.documentTypes": [
"markdown",
"latex",
"plaintext"
]
}
11 changes: 3 additions & 8 deletions app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"deep-equal": "^1.0.1",
"dexie": "^2.0.0",
"double-ended-queue": "^2.1.0-0",
"dugite": "1.91.3",
"dugite": "1.92.0",
"electron-window-state": "^5.0.3",
"event-kit": "^2.0.0",
"file-metadata": "^1.0.0",
Expand All @@ -47,6 +47,7 @@
"p-limit": "^2.2.0",
"pretty-bytes": "^5.1.0",
"primer-support": "^4.0.0",
"prop-types": "^15.7.2",
"queue": "^5.0.0",
"quick-lru": "^3.0.0",
"react": "^16.8.4",
Expand All @@ -63,7 +64,6 @@
"stripe": "4.22.0",
"textarea-caret": "^3.0.2",
"tslib": "^2.0.0",
"ua-parser-js": "^0.7.12",
"untildify": "^3.0.2",
"username": "^2.3.0",
"uuid": "^3.0.1",
Expand Down
30 changes: 23 additions & 7 deletions app/src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,23 @@ export interface IAPIRepository {
readonly pushed_at: string
readonly has_issues: boolean
readonly archived: boolean
readonly parent?: IAPIRepository
}

export interface IAPIFullRepository extends IAPIRepository {
/**
* The parent repository of a fork.
*
* HACK: BEWARE: This is defined as `parent: IAPIRepository | undefined`
* rather than `parent?: ...` even though the parent property is actually
* optional in the API response. So we're lying a bit to the type system
* here saying that this will be present but the only time the difference
* between omission and explicit undefined matters is when using constructs
* like `x in y` or `y.hasOwnProperty('x')` which we do very rarely.
*
* Without at least one non-optional type in this interface TypeScript will
* happily let us pass an IAPIRepository in place of an IAPIFullRepository.
*/
readonly parent: IAPIRepository | undefined

/**
* The high-level permissions that the currently authenticated
Expand Down Expand Up @@ -607,14 +623,14 @@ export class API {
public async fetchRepository(
owner: string,
name: string
): Promise<IAPIRepository | null> {
): Promise<IAPIFullRepository | null> {
try {
const response = await this.request('GET', `repos/${owner}/${name}`)
if (response.status === HttpStatusCode.NotFound) {
log.warn(`fetchRepository: '${owner}/${name}' returned a 404`)
return null
}
return await parsedResponse<IAPIRepository>(response)
return await parsedResponse<IAPIFullRepository>(response)
} catch (e) {
log.warn(`fetchRepository: an error occurred for '${owner}/${name}'`, e)
return null
Expand Down Expand Up @@ -715,7 +731,7 @@ export class API {
name: string,
description: string,
private_: boolean
): Promise<IAPIRepository> {
): Promise<IAPIFullRepository> {
try {
const apiPath = org ? `orgs/${org.login}/repos` : 'user/repos'
const response = await this.request('POST', apiPath, {
Expand All @@ -724,7 +740,7 @@ export class API {
private: private_,
})

return await parsedResponse<IAPIRepository>(response)
return await parsedResponse<IAPIFullRepository>(response)
} catch (e) {
if (e instanceof APIError) {
if (org !== null) {
Expand All @@ -746,11 +762,11 @@ export class API {
public async forkRepository(
owner: string,
name: string
): Promise<IAPIRepository> {
): Promise<IAPIFullRepository> {
try {
const apiPath = `/repos/${owner}/${name}/forks`
const response = await this.request('POST', apiPath)
return await parsedResponse<IAPIRepository>(response)
return await parsedResponse<IAPIFullRepository>(response)
} catch (e) {
log.error(
`forkRepository: failed to fork ${owner}/${name} at endpoint: ${this.endpoint}`,
Expand Down
28 changes: 2 additions & 26 deletions app/src/lib/app-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import { GitRebaseProgress } from '../models/rebase'
import { RebaseFlowStep } from '../models/rebase-flow-step'
import { IStashEntry } from '../models/stash-entry'
import { TutorialStep } from '../models/tutorial-step'
import { UncommittedChangesStrategyKind } from '../models/uncommitted-changes-strategy'
import { UncommittedChangesStrategy } from '../models/uncommitted-changes-strategy'

export enum SelectionType {
Repository,
Expand Down Expand Up @@ -180,7 +180,7 @@ export interface IAppState {
readonly askForConfirmationOnForcePush: boolean

/** How the app should handle uncommitted changes when switching branches */
readonly uncommittedChangesStrategyKind: UncommittedChangesStrategyKind
readonly uncommittedChangesStrategy: UncommittedChangesStrategy

/** The external editor to use when opening repositories */
readonly selectedExternalEditor: ExternalEditor | null
Expand Down Expand Up @@ -697,9 +697,6 @@ export interface ICompareBranch {
}

export interface ICompareState {
/** The current state of the NBBD banner */
readonly divergingBranchBannerState: IDivergingBranchBannerState

/** The current state of the compare form, based on user input */
readonly formState: IDisplayHistory | ICompareBranch

Expand Down Expand Up @@ -745,27 +742,6 @@ export interface ICompareState {
* A local cache of ahead/behind computations to compare other refs to the current branch
*/
readonly aheadBehindCache: ComparisonCache

/**
* The best candidate branch to compare the current branch to.
* Also includes the ahead/behind info for the inferred branch
* relative to the current branch.
*/
readonly inferredComparisonBranch: {
branch: Branch | null
aheadBehind: IAheadBehind | null
}
}

export interface IDivergingBranchBannerState {
/** Show the diverging notification banner */
readonly isPromptVisible: boolean

/** Has the user dismissed the notification banner? */
readonly isPromptDismissed: boolean

/** Show the diverging notification nudge on the tab */
readonly isNudgeVisible: boolean
}

export interface ICompareFormUpdate {
Expand Down
36 changes: 2 additions & 34 deletions app/src/lib/databases/pull-request-database.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Dexie from 'dexie'
import { BaseDatabase } from './base-database'
import { GitHubRepository } from '../../models/github-repository'
import { fatalError, forceUnwrap } from '../fatal-error'

export interface IPullRequestRef {
/**
Expand Down Expand Up @@ -134,11 +133,6 @@ export class PullRequestDatabase extends BaseDatabase {
* if it exists.
*/
public async deleteAllPullRequestsInRepository(repository: GitHubRepository) {
const dbId = forceUnwrap(
"Can't delete PRs for repository, no dbId",
repository.dbID
)

await this.transaction(
'rw',
this.pullRequests,
Expand All @@ -147,7 +141,7 @@ export class PullRequestDatabase extends BaseDatabase {
await this.clearLastUpdated(repository)
await this.pullRequests
.where('[base.repoId+number]')
.between([dbId], [dbId + 1])
.between([repository.dbID], [repository.dbID + 1])
.delete()
}
)
Expand Down Expand Up @@ -180,10 +174,6 @@ export class PullRequestDatabase extends BaseDatabase {
* yet been inserted into the database (i.e the dbID field is null).
*/
public getAllPullRequestsInRepository(repository: GitHubRepository) {
if (repository.dbID === null) {
return fatalError("Can't retrieve PRs for repository, no dbId")
}

return this.pullRequests
.where('[base.repoId+number]')
.between([repository.dbID], [repository.dbID + 1])
Expand All @@ -194,10 +184,6 @@ export class PullRequestDatabase extends BaseDatabase {
* Get a single pull requests for a particular repository
*/
public getPullRequest(repository: GitHubRepository, prNumber: number) {
if (repository.dbID === null) {
return fatalError("Can't retrieve PRs for repository with a null dbID")
}

return this.pullRequests.get([repository.dbID, prNumber])
}

Expand All @@ -212,10 +198,6 @@ export class PullRequestDatabase extends BaseDatabase {
* table.
*/
public async getLastUpdated(repository: GitHubRepository) {
if (repository.dbID === null) {
return fatalError("Can't retrieve PRs for repository with a null dbID")
}

const row = await this.pullRequestsLastUpdated.get(repository.dbID)

return row ? new Date(row.lastUpdated) : null
Expand All @@ -226,12 +208,6 @@ export class PullRequestDatabase extends BaseDatabase {
* a given repository.
*/
public async clearLastUpdated(repository: GitHubRepository) {
if (repository.dbID === null) {
throw new Error(
"Can't clear last updated PR for repository with a null dbID"
)
}

await this.pullRequestsLastUpdated.delete(repository.dbID)
}

Expand All @@ -246,10 +222,6 @@ export class PullRequestDatabase extends BaseDatabase {
* table.
*/
public async setLastUpdated(repository: GitHubRepository, lastUpdated: Date) {
if (repository.dbID === null) {
throw new Error("Can't set last updated for PR with a null dbID")
}

await this.pullRequestsLastUpdated.put({
repoId: repository.dbID,
lastUpdated: lastUpdated.getTime(),
Expand All @@ -271,9 +243,5 @@ export function getPullRequestKey(
repository: GitHubRepository,
prNumber: number
) {
const dbId = forceUnwrap(
`Can get key for PR, repository not inserted in database.`,
repository.dbID
)
return [dbId, prNumber] as PullRequestKey
return [repository.dbID, prNumber] as PullRequestKey
}
10 changes: 7 additions & 3 deletions app/src/lib/databases/repositories-database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { BaseDatabase } from './base-database'
import { WorkflowPreferences } from '../../models/workflow-preferences'

export interface IDatabaseOwner {
readonly id?: number | null
readonly id?: number
readonly login: string
readonly endpoint: string
}

export interface IDatabaseGitHubRepository {
readonly id?: number | null
readonly id?: number
readonly ownerID: number
readonly name: string
readonly private: boolean | null
Expand Down Expand Up @@ -41,7 +41,7 @@ export interface IDatabaseProtectedBranch {
}

export interface IDatabaseRepository {
readonly id?: number | null
readonly id?: number
readonly gitHubRepositoryID: number | null
readonly path: string
readonly missing: boolean
Expand Down Expand Up @@ -118,6 +118,10 @@ export class RepositoriesDatabase extends BaseDatabase {
this.conditionalVersion(6, {
protectedBranches: '[repoId+name], repoId',
})

this.conditionalVersion(7, {
gitHubRepositories: '++id, &[ownerID+name]',
})
}
}

Expand Down
Loading

0 comments on commit 51beb8a

Please sign in to comment.