Skip to content

Commit

Permalink
Merge branch 'master' into disallowed-characters-shall-not-pass
Browse files Browse the repository at this point in the history
  • Loading branch information
nerdneha committed Dec 12, 2017
2 parents ce18135 + 5f52689 commit 150d61a
Show file tree
Hide file tree
Showing 38 changed files with 404 additions and 545 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ cache:
- node_modules
- $HOME/.electron
- .eslintcache
- $HOME/.cache/electron-builder

before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.3.2
Expand Down
4 changes: 1 addition & 3 deletions app/git-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ function revParse(gitDir, ref) {

if (!refMatch) {
throw new Error(
`Could not de-reference HEAD to SHA, invalid ref in ${refPath}: ${
refContents
}`
`Could not de-reference HEAD to SHA, invalid ref in ${refPath}: ${refContents}`
)
}

Expand Down
2 changes: 1 addition & 1 deletion 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": "1.0.11-beta0",
"version": "1.0.11-test0",
"main": "./main.js",
"repository": {
"type": "git",
Expand Down
4 changes: 1 addition & 3 deletions app/src/cli/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,7 @@ function runCommand(name: string) {
throw new CommandError(
`Value passed to flag ${dasherizeOption(
flag
)} was of type ${typeof value}, but was expected to be of type ${
expectedType
}`
)} was of type ${typeof value}, but was expected to be of type ${expectedType}`
)
}
}
Expand Down
12 changes: 3 additions & 9 deletions app/src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,7 @@ export class API {
return status
} catch (e) {
log.warn(
`fetchCombinedRefStatus: failed for repository ${owner}/${
name
} on ref ${ref}`,
`fetchCombinedRefStatus: failed for repository ${owner}/${name} on ref ${ref}`,
e
)
throw e
Expand Down Expand Up @@ -722,9 +720,7 @@ async function getNote(): Promise<string> {
localUsername = await username()
} catch (e) {
log.error(
`getNote: unable to resolve machine username, using '${
localUsername
}' as a fallback`,
`getNote: unable to resolve machine username, using '${localUsername}' as a fallback`,
e
)
}
Expand Down Expand Up @@ -804,9 +800,7 @@ export function getOAuthAuthorizationURL(
): string {
const urlBase = getHTMLURL(endpoint)
const scope = encodeURIComponent(Scopes.join(' '))
return `${urlBase}/login/oauth/authorize?client_id=${ClientID}&scope=${
scope
}&state=${state}`
return `${urlBase}/login/oauth/authorize?client_id=${ClientID}&scope=${scope}&state=${state}`
}

export async function requestOAuthToken(
Expand Down
4 changes: 1 addition & 3 deletions app/src/lib/diff-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,7 @@ export class DiffParser {
if (!str) {
if (!defaultValue) {
throw new Error(
`Group ${
group
} missing from regexp match and no defaultValue was provided`
`Group ${group} missing from regexp match and no defaultValue was provided`
)
}

Expand Down
10 changes: 4 additions & 6 deletions app/src/lib/dispatcher/dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,7 @@ export class Dispatcher {

if (currentError) {
fatalError(
`Unhandled error ${
currentError
}. This shouldn't happen! All errors should be handled, even if it's just by the default handler.`
`Unhandled error ${currentError}. This shouldn't happen! All errors should be handled, even if it's just by the default handler.`
)
}
}
Expand Down Expand Up @@ -805,9 +803,9 @@ export class Dispatcher {
this.handleCloneInDesktopOptions(repository, action)
} else {
log.warn(
`Open Repository from URL failed, did not find repository: ${
url
} - payload: ${JSON.stringify(action)}`
`Open Repository from URL failed, did not find repository: ${url} - payload: ${JSON.stringify(
action
)}`
)
}
break
Expand Down
4 changes: 1 addition & 3 deletions app/src/lib/editors/lookup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ export async function findEditorOrDefault(
const match = editors.find(p => p.editor === name) || null
if (!match) {
const menuItemName = __DARWIN__ ? 'Preferences' : 'Options'
const message = `The editor '${name}' could not be found. Please open ${
menuItemName
} and choose an available editor.`
const message = `The editor '${name}' could not be found. Please open ${menuItemName} and choose an available editor.`

throw new ExternalEditorError(message, { openPreferences: true })
}
Expand Down
11 changes: 1 addition & 10 deletions app/src/lib/git/clone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,7 @@ export async function clone(
): Promise<void> {
const env = envForAuthentication(options.account)

const args = [
...gitNetworkArguments,
'lfs',
'clone',
'--recursive',
// git-lfs will create the hooks it requires by default
// and we don't know if the repository is LFS enabled
// at this stage so let's not do this
'--skip-repo',
]
const args = [...gitNetworkArguments, 'clone', '--recursive']

let opts: IGitExecutionOptions = { env }

Expand Down
13 changes: 13 additions & 0 deletions app/src/lib/git/merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,16 @@ export async function merge(
): Promise<void> {
await git(['merge', branch], repository.path, 'merge')
}

export async function getMergeBase(
repository: Repository,
firstRef: string,
secondRef: string
): Promise<string> {
const process = await git(
['merge-base', firstRef, secondRef],
repository.path,
'merge-base'
)
return process.stdout.trim()
}
4 changes: 1 addition & 3 deletions app/src/lib/git/spawn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ export function spawnAndComplete(
} else {
reject(
new Error(
`Git returned an unexpected exit code '${
code
}' which should be handled by the caller.'`
`Git returned an unexpected exit code '${code}' which should be handled by the caller.'`
)
)
}
Expand Down
4 changes: 1 addition & 3 deletions app/src/lib/open-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ export async function openFile(
if (!result) {
const error = {
name: 'no-external-program',
message: `Unable to open file ${
fullPath
} in an external program. Please check you have a program associated with this file extension`,
message: `Unable to open file ${fullPath} in an external program. Please check you have a program associated with this file extension`,
}
await dispatcher.postError(error)
}
Expand Down
45 changes: 27 additions & 18 deletions app/src/lib/stores/app-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ import {
checkoutBranch,
getDefaultRemote,
formatAsLocalRef,
getMergeBase,
} from '../git'

import { launchExternalEditor } from '../editors'
Expand Down Expand Up @@ -908,9 +909,7 @@ export class AppStore {
const timeInSeconds = Math.floor(timeSinceFetch / 1000)

log.debug(
`skipping background fetch as repository was fetched ${
timeInSeconds
}s ago`
`skipping background fetch as repository was fetched ${timeInSeconds}s ago`
)
return false
}
Expand Down Expand Up @@ -1965,16 +1964,26 @@ export class AppStore {
}

const state = this.getRepositoryState(repository)
const tip = state.branchesState.tip

if (state.branchesState.tip.kind === TipState.Unborn) {
if (tip.kind === TipState.Unborn) {
throw new Error('The current branch is unborn.')
}

if (state.branchesState.tip.kind === TipState.Detached) {
if (tip.kind === TipState.Detached) {
throw new Error('The current repository is in a detached HEAD state.')
}

if (state.branchesState.tip.kind === TipState.Valid) {
if (tip.kind === TipState.Valid) {
let mergeBase: string | null = null
if (tip.branch.upstream) {
mergeBase = await getMergeBase(
repository,
tip.branch.name,
tip.branch.upstream
)
}

const title = `Pulling ${remote.name}`
const kind = 'pull'
this.updatePushPullFetchProgress(repository, {
Expand Down Expand Up @@ -2025,6 +2034,10 @@ export class AppStore {
value: refreshStartProgress,
})

if (mergeBase) {
await gitStore.reconcileHistory(mergeBase)
}

await this._refreshRepository(repository)

this.updatePushPullFetchProgress(repository, {
Expand Down Expand Up @@ -2130,9 +2143,9 @@ export class AppStore {
const hasValidToken =
account.token.length > 0 ? 'has token' : 'empty token'
log.info(
`[AppStore.getAccountForRemoteURL] account found for remote: ${
remote
} - ${account.login} (${hasValidToken})`
`[AppStore.getAccountForRemoteURL] account found for remote: ${remote} - ${
account.login
} (${hasValidToken})`
)
return account
}
Expand All @@ -2142,17 +2155,13 @@ export class AppStore {
const username = getGenericUsername(hostname)
if (username != null) {
log.info(
`[AppStore.getAccountForRemoteURL] found generic credentials for '${
hostname
}' and '${username}'`
`[AppStore.getAccountForRemoteURL] found generic credentials for '${hostname}' and '${username}'`
)
return { login: username, endpoint: hostname }
}

log.info(
`[AppStore.getAccountForRemoteURL] no generic credentials found for '${
remote
}'`
`[AppStore.getAccountForRemoteURL] no generic credentials found for '${remote}'`
)

return null
Expand Down Expand Up @@ -3070,9 +3079,9 @@ export class AppStore {

const branch = tip.branch
const urlEncodedBranchName = QueryString.escape(branch.nameWithoutRemote)
const baseURL = `${gitHubRepository.htmlURL}/pull/new/${
urlEncodedBranchName
}`
const baseURL = `${
gitHubRepository.htmlURL
}/pull/new/${urlEncodedBranchName}`

await this._openInBrowser(baseURL)
}
Expand Down
46 changes: 46 additions & 0 deletions app/src/lib/stores/git-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,52 @@ export class GitStore {
return this.emitter.on('did-error', fn)
}

/**
* Reconcile the local history view with the repository state
* after a pull has completed, to include merged remote commits.
*/
public async reconcileHistory(mergeBase: string): Promise<void> {
if (this._history.length === 0) {
return
}

if (this.requestsInFight.has(LoadingHistoryRequestKey)) {
return
}

this.requestsInFight.add(LoadingHistoryRequestKey)

const commits = await this.performFailableOperation(() =>
getCommits(this.repository, `HEAD..${mergeBase}`, CommitBatchSize)
)
if (commits == null) {
return
}

const existingHistory = this._history
const index = existingHistory.findIndex(c => c === mergeBase)

if (index > -1) {
log.debug(
`reconciling history - adding ${
commits.length
} commits before merge base ${mergeBase.substr(0, 8)}`
)

// rebuild the local history state by combining the commits _before_ the
// merge base with the current commits on the tip of this current branch
const remainingHistory = existingHistory.slice(index)
this._history = [...commits.map(c => c.sha), ...remainingHistory]
}

this.storeCommits(commits)

this.requestsInFight.delete(LoadingHistoryRequestKey)

this.emitNewCommitsLoaded(commits)
this.emitUpdate()
}

/** Load history from HEAD. */
public async loadHistory() {
if (this.requestsInFight.has(LoadingHistoryRequestKey)) {
Expand Down
4 changes: 1 addition & 3 deletions app/src/lib/stores/github-user-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,7 @@ export class GitHubUserStore {
const userID = user.id
if (!userID) {
fatalError(
`Cannot prune removed mentionables with a user that hasn't been cached yet: ${
user
}`
`Cannot prune removed mentionables with a user that hasn't been cached yet: ${user}`
)
return
}
Expand Down
12 changes: 3 additions & 9 deletions app/src/lib/stores/sign-in-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ import { AuthenticationMode } from '../../lib/2fa'
import { minimumSupportedEnterpriseVersion } from '../../lib/enterprise'

function getUnverifiedUserErrorMessage(login: string): string {
return `Unable to authenticate. The account ${
login
} is lacking a verified email address. Please sign in to GitHub.com, confirm your email address in the Emails section under Personal settings, and try again.`
return `Unable to authenticate. The account ${login} is lacking a verified email address. Please sign in to GitHub.com, confirm your email address in the Emails section under Personal settings, and try again.`
}

const EnterpriseTooOldMessage = `The GitHub Enterprise version does not support GitHub Desktop. Talk to your server's administrator about upgrading to the latest version of GitHub Enterprise.`
Expand Down Expand Up @@ -236,9 +234,7 @@ export class SignInStore {
}
} else {
throw new Error(
`Unable to authenticate with the GitHub Enterprise instance. Verify that the URL is correct, that your GitHub Enterprise instance is running version ${
minimumSupportedEnterpriseVersion
} or later, that you have an internet connection and try again.`
`Unable to authenticate with the GitHub Enterprise instance. Verify that the URL is correct, that your GitHub Enterprise instance is running version ${minimumSupportedEnterpriseVersion} or later, that you have an internet connection and try again.`
)
}
}
Expand Down Expand Up @@ -535,9 +531,7 @@ export class SignInStore {
) {
const stepText = currentState ? currentState.kind : 'null'
fatalError(
`Sign in step '${
stepText
}' not compatible with two factor authentication`
`Sign in step '${stepText}' not compatible with two factor authentication`
)
return
}
Expand Down
8 changes: 2 additions & 6 deletions app/src/ui/add-repository/create-repository.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,7 @@ export class CreateRepository extends React.Component<
} catch (e) {
this.setState({ creating: false })
log.error(
`createRepository: unable to initialize a Git repository at ${
fullPath
}`,
`createRepository: unable to initialize a Git repository at ${fullPath}`,
e
)
return this.props.dispatcher.postError(e)
Expand Down Expand Up @@ -244,9 +242,7 @@ export class CreateRepository extends React.Component<
await writeGitDescription(fullPath, description)
} catch (e) {
log.error(
`createRepository: unable to write .git/description file at ${
fullPath
}`,
`createRepository: unable to write .git/description file at ${fullPath}`,
e
)
this.props.dispatcher.postError(e)
Expand Down
Loading

0 comments on commit 150d61a

Please sign in to comment.