Skip to content

Commit

Permalink
Merge pull request #66 from yasuking0304/development
Browse files Browse the repository at this point in the history
Version 3.4.6
  • Loading branch information
yasuking0304 authored Oct 8, 2024
2 parents 1bd88d5 + 4839518 commit bcb1c70
Show file tree
Hide file tree
Showing 58 changed files with 784 additions and 634 deletions.
3 changes: 2 additions & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!--
What GitHub Desktop issue does this PR address? (for example, #1234)
What GitHub Desktop issue does this PR address (for example, #1234)?
If you have not created an issue for your PR, please search the issue tracker to see if there is an existing issue that aligns with your PR, or open a new issue for discussion.
-->

Closes #[issue number]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ on:
APPLE_APPLICATION_CERT_PASSWORD:

env:
NODE_VERSION: 20.11.1
NODE_VERSION: 20.17.0

jobs:
build:
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/close-invalid.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Close issue/PR on adding invalid label

# **What it does**: This action closes issues and PRs that are labeled as invalid in the Desktop repo.

on:
issues:
types: [labeled]
# Needed in lieu of `pull_request` so that PRs from a fork can be
# closed when marked as invalid.
pull_request_target:
types: [labeled]

permissions:
contents: read
issues: write
pull-requests: write

jobs:
close-on-adding-invalid-label:
if:
github.repository == 'desktop/desktop' && github.event.label.name ==
'invalid'
runs-on: ubuntu-latest

steps:
- name: Close issue
if: ${{ github.event_name == 'issues' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh issue close ${{ github.event.issue.html_url }}

- name: Close PR
if: ${{ github.event_name == 'pull_request_target' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr close ${{ github.event.pull_request.html_url }}
18 changes: 18 additions & 0 deletions .github/workflows/triage-issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Label incoming issues
on:
issues:
types:
- reopened
- opened
jobs:
label_issues:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- run: gh issue edit "$NUMBER" --add-label "$LABELS"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
NUMBER: ${{ github.event.issue.number }}
LABELS: triage
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.11.1
20.17.0
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v20.11.1
v20.17.0
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
python 3.9.5
nodejs 20.11.1
nodejs 20.17.0
4 changes: 2 additions & 2 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": "3.4.5",
"version": "3.4.6",
"main": "./main.js",
"repository": {
"type": "git",
Expand Down Expand Up @@ -32,7 +32,7 @@
"desktop-notifications": "^0.2.4",
"desktop-trampoline": "desktop/desktop-trampoline#v0.9.10",
"dexie": "^3.2.2",
"dompurify": "^2.3.3",
"dompurify": "^2.5.4",
"dugite": "3.0.0-rc3",
"electron-window-state": "^5.0.3",
"event-kit": "^2.0.0",
Expand Down
42 changes: 40 additions & 2 deletions app/src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ import {
isGHE,
updateEndpointVersion,
} from './endpoint-capabilities'
import {
clearCertificateErrorSuppressionFor,
suppressCertificateErrorFor,
} from './suppress-certificate-error'

const envEndpoint = process.env['DESKTOP_GITHUB_DOTCOM_API_ENDPOINT']
const envHTMLURL = process.env['DESKTOP_GITHUB_DOTCOM_HTML_URL']
Expand Down Expand Up @@ -2136,6 +2140,18 @@ export function getHTMLURL(endpoint: string): string {
if (endpoint === getDotComAPIEndpoint() && !envEndpoint) {
return 'https://github.com'
} else {
if (isGHE(endpoint)) {
const url = new window.URL(endpoint)

url.pathname = '/'

if (url.hostname.startsWith('api.')) {
url.hostname = url.hostname.replace(/^api\./, '')
}

return url.toString()
}

const parsed = URL.parse(endpoint)
return `${parsed.protocol}//${parsed.hostname}`
}
Expand All @@ -2147,6 +2163,15 @@ export function getHTMLURL(endpoint: string): string {
* http://github.mycompany.com -> http://github.mycompany.com/api/v3
*/
export function getEnterpriseAPIURL(endpoint: string): string {
if (isGHE(endpoint)) {
const url = new window.URL(endpoint)

url.pathname = '/'
url.hostname = `api.${url.hostname}`

return url.toString()
}

const parsed = URL.parse(endpoint)
return `${parsed.protocol}//${parsed.hostname}/api/v3`
}
Expand Down Expand Up @@ -2263,6 +2288,11 @@ export async function isGitHubHost(url: string) {
return false
}

// github.example.com,
if (/(^|\.)(github)\./.test(hostname)) {
return true
}

// bitbucket.example.com, etc
if (/(^|\.)(bitbucket|gitlab)\./.test(hostname)) {
return false
Expand All @@ -2272,21 +2302,29 @@ export async function isGitHubHost(url: string) {
return true
}

// Add a unique identifier to the URL to make sure our certificate error
// supression only catches this request
const metaUrl = `${endpoint}/meta?ghd=${uuid()}`

const ac = new AbortController()
const timeoutId = setTimeout(() => ac.abort(), 2000)
suppressCertificateErrorFor(metaUrl)
try {
const response = await fetch(`${endpoint}/meta`, {
const response = await fetch(metaUrl, {
headers: { 'user-agent': getUserAgent() },
signal: ac.signal,
credentials: 'omit',
method: 'HEAD',
}).finally(() => clearTimeout(timeoutId))
})

tryUpdateEndpointVersionFromResponse(endpoint, response)

return response.headers.has('x-github-request-id')
} catch (e) {
log.debug(`isGitHubHost: failed with endpoint ${endpoint}`, e)
return undefined
} finally {
clearTimeout(timeoutId)
clearCertificateErrorSuppressionFor(metaUrl)
}
}
16 changes: 1 addition & 15 deletions app/src/lib/feature-flag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,24 +81,10 @@ export function enablePullRequestQuickView(): boolean {
return enableDevelopmentFeatures()
}

export function enableMoveStash(): boolean {
return true
}

export const enableRepoRulesBeta = () => true

export const enableCommitDetailsHeaderExpansion = () => true

export const enableDiffCheckMarksAndLinkUnderlines = () => true

export const enableDiffCheckMarks = enableDiffCheckMarksAndLinkUnderlines
export const enableGroupDiffCheckmarks = enableDiffCheckMarksAndLinkUnderlines

export const enableLinkUnderlines = enableDiffCheckMarksAndLinkUnderlines

export const enableExternalCredentialHelper = () => true
export const enableCredentialHelperTrampoline = () => true

export const enableCustomIntegration = () => true

export const enableResizingToolbarButtons = enableBetaFeatures
export const enableGitConfigParameters = enableBetaFeatures
5 changes: 3 additions & 2 deletions app/src/lib/git/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export class GitError extends Error {
} else if (result.stdout.length) {
message = result.stdout
} else {
message = 'Unknown error'
message = `Unknown error (exit code ${result.exitCode})`
rawMessage = false
}

Expand Down Expand Up @@ -257,7 +257,8 @@ export async function git(
throw new GitError(gitResult, args)
},
path,
options?.isBackgroundTask ?? false
options?.isBackgroundTask ?? false,
options?.env
)
}

Expand Down
50 changes: 41 additions & 9 deletions app/src/lib/git/diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { spawnAndComplete } from './spawn'

import { DiffParser } from '../diff-parser'
import { getOldPathOrDefault } from '../get-old-path'
import { getCaptures } from '../helpers/regex'
import { readFile } from 'fs/promises'
import { forceUnwrap } from '../fatal-error'
import { git } from './core'
Expand All @@ -34,6 +33,8 @@ import { GitError } from 'dugite'
import { IChangesetData, parseRawLogWithNumstat } from './log'
import { getConfigValue } from './config'
import { getMergeBase } from './merge'
import { IStatusEntry } from '../status-parser'
import { createLogParser } from './git-delimiter-parser'

/**
* V8 has a limit on the size of string it can create (~256MB), and unless we want to
Expand Down Expand Up @@ -716,20 +717,51 @@ export async function getWorkingDirectoryImage(
*/
export async function getBinaryPaths(
repository: Repository,
ref: string
ref: string,
conflictedFilesInIndex: ReadonlyArray<IStatusEntry>
): Promise<ReadonlyArray<string>> {
const [detectedBinaryFiles, conflictedFilesUsingBinaryMergeDriver] =
await Promise.all([
getDetectedBinaryFiles(repository, ref),
getFilesUsingBinaryMergeDriver(repository, conflictedFilesInIndex),
])

return Array.from(
new Set([...detectedBinaryFiles, ...conflictedFilesUsingBinaryMergeDriver])
)
}

/**
* Runs diff --numstat to get the list of files that have changed and which
* Git have detected as binary files
*/
async function getDetectedBinaryFiles(repository: Repository, ref: string) {
const { output } = await spawnAndComplete(
['diff', '--numstat', '-z', ref],
repository.path,
'getBinaryPaths'
)
const captures = getCaptures(output.toString('utf8'), binaryListRegex)
if (captures.length === 0) {
return []
}
// flatten the list (only does one level deep)
const flatCaptures = captures.reduce((acc, val) => acc.concat(val))
return flatCaptures

return Array.from(output.toString().matchAll(binaryListRegex), m => m[1])
}

const binaryListRegex = /-\t-\t(?:\0.+\0)?([^\0]*)/gi

async function getFilesUsingBinaryMergeDriver(
repository: Repository,
files: ReadonlyArray<IStatusEntry>
) {
const { stdout } = await git(
['check-attr', '--stdin', '-z', 'merge'],
repository.path,
'getConflictedFilesUsingBinaryMergeDriver',
{
stdin: files.map(f => f.path).join('\0'),
}
)

return createLogParser({ path: '', attr: '', value: '' })
.parse(stdout)
.filter(x => x.attr === 'merge' && x.value === 'binary')
.map(x => x.path)
}
1 change: 1 addition & 0 deletions app/src/lib/git/rebase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@ export async function rebaseInteractive(
const baseOptions: IGitExecutionOptions = {
expectedErrors: new Set([GitError.RebaseConflicts]),
env: {
GIT_SEQUENCE_EDITOR: undefined,
GIT_EDITOR: gitEditor,
},
}
Expand Down
3 changes: 2 additions & 1 deletion app/src/lib/git/spawn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ export const spawnGit = (
})
),
path,
options?.isBackgroundTask ?? false
options?.isBackgroundTask ?? false,
options?.env
)

/**
Expand Down
Loading

0 comments on commit bcb1c70

Please sign in to comment.