Skip to content

Commit bcb1c70

Browse files
authored
Merge pull request #66 from yasuking0304/development
Version 3.4.6
2 parents 1bd88d5 + 4839518 commit bcb1c70

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+784
-634
lines changed

.github/pull_request_template.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<!--
2-
What GitHub Desktop issue does this PR address? (for example, #1234)
2+
What GitHub Desktop issue does this PR address (for example, #1234)?
3+
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.
34
-->
45

56
Closes #[issue number]

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ on:
4242
APPLE_APPLICATION_CERT_PASSWORD:
4343

4444
env:
45-
NODE_VERSION: 20.11.1
45+
NODE_VERSION: 20.17.0
4646

4747
jobs:
4848
build:

.github/workflows/close-invalid.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Close issue/PR on adding invalid label
2+
3+
# **What it does**: This action closes issues and PRs that are labeled as invalid in the Desktop repo.
4+
5+
on:
6+
issues:
7+
types: [labeled]
8+
# Needed in lieu of `pull_request` so that PRs from a fork can be
9+
# closed when marked as invalid.
10+
pull_request_target:
11+
types: [labeled]
12+
13+
permissions:
14+
contents: read
15+
issues: write
16+
pull-requests: write
17+
18+
jobs:
19+
close-on-adding-invalid-label:
20+
if:
21+
github.repository == 'desktop/desktop' && github.event.label.name ==
22+
'invalid'
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- name: Close issue
27+
if: ${{ github.event_name == 'issues' }}
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
run: gh issue close ${{ github.event.issue.html_url }}
31+
32+
- name: Close PR
33+
if: ${{ github.event_name == 'pull_request_target' }}
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
run: gh pr close ${{ github.event.pull_request.html_url }}

.github/workflows/triage-issues.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Label incoming issues
2+
on:
3+
issues:
4+
types:
5+
- reopened
6+
- opened
7+
jobs:
8+
label_issues:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
issues: write
12+
steps:
13+
- run: gh issue edit "$NUMBER" --add-label "$LABELS"
14+
env:
15+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16+
GH_REPO: ${{ github.repository }}
17+
NUMBER: ${{ github.event.issue.number }}
18+
LABELS: triage

.node-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20.11.1
1+
20.17.0

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v20.11.1
1+
v20.17.0

.tool-versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
python 3.9.5
2-
nodejs 20.11.1
2+
nodejs 20.17.0

app/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"productName": "GitHub Desktop",
44
"bundleID": "com.github.GitHubClient",
55
"companyName": "GitHub, Inc.",
6-
"version": "3.4.5",
6+
"version": "3.4.6",
77
"main": "./main.js",
88
"repository": {
99
"type": "git",
@@ -32,7 +32,7 @@
3232
"desktop-notifications": "^0.2.4",
3333
"desktop-trampoline": "desktop/desktop-trampoline#v0.9.10",
3434
"dexie": "^3.2.2",
35-
"dompurify": "^2.3.3",
35+
"dompurify": "^2.5.4",
3636
"dugite": "3.0.0-rc3",
3737
"electron-window-state": "^5.0.3",
3838
"event-kit": "^2.0.0",

app/src/lib/api.ts

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ import {
2020
isGHE,
2121
updateEndpointVersion,
2222
} from './endpoint-capabilities'
23+
import {
24+
clearCertificateErrorSuppressionFor,
25+
suppressCertificateErrorFor,
26+
} from './suppress-certificate-error'
2327

2428
const envEndpoint = process.env['DESKTOP_GITHUB_DOTCOM_API_ENDPOINT']
2529
const envHTMLURL = process.env['DESKTOP_GITHUB_DOTCOM_HTML_URL']
@@ -2136,6 +2140,18 @@ export function getHTMLURL(endpoint: string): string {
21362140
if (endpoint === getDotComAPIEndpoint() && !envEndpoint) {
21372141
return 'https://github.com'
21382142
} else {
2143+
if (isGHE(endpoint)) {
2144+
const url = new window.URL(endpoint)
2145+
2146+
url.pathname = '/'
2147+
2148+
if (url.hostname.startsWith('api.')) {
2149+
url.hostname = url.hostname.replace(/^api\./, '')
2150+
}
2151+
2152+
return url.toString()
2153+
}
2154+
21392155
const parsed = URL.parse(endpoint)
21402156
return `${parsed.protocol}//${parsed.hostname}`
21412157
}
@@ -2147,6 +2163,15 @@ export function getHTMLURL(endpoint: string): string {
21472163
* http://github.mycompany.com -> http://github.mycompany.com/api/v3
21482164
*/
21492165
export function getEnterpriseAPIURL(endpoint: string): string {
2166+
if (isGHE(endpoint)) {
2167+
const url = new window.URL(endpoint)
2168+
2169+
url.pathname = '/'
2170+
url.hostname = `api.${url.hostname}`
2171+
2172+
return url.toString()
2173+
}
2174+
21502175
const parsed = URL.parse(endpoint)
21512176
return `${parsed.protocol}//${parsed.hostname}/api/v3`
21522177
}
@@ -2263,6 +2288,11 @@ export async function isGitHubHost(url: string) {
22632288
return false
22642289
}
22652290

2291+
// github.example.com,
2292+
if (/(^|\.)(github)\./.test(hostname)) {
2293+
return true
2294+
}
2295+
22662296
// bitbucket.example.com, etc
22672297
if (/(^|\.)(bitbucket|gitlab)\./.test(hostname)) {
22682298
return false
@@ -2272,21 +2302,29 @@ export async function isGitHubHost(url: string) {
22722302
return true
22732303
}
22742304

2305+
// Add a unique identifier to the URL to make sure our certificate error
2306+
// supression only catches this request
2307+
const metaUrl = `${endpoint}/meta?ghd=${uuid()}`
2308+
22752309
const ac = new AbortController()
22762310
const timeoutId = setTimeout(() => ac.abort(), 2000)
2311+
suppressCertificateErrorFor(metaUrl)
22772312
try {
2278-
const response = await fetch(`${endpoint}/meta`, {
2313+
const response = await fetch(metaUrl, {
22792314
headers: { 'user-agent': getUserAgent() },
22802315
signal: ac.signal,
22812316
credentials: 'omit',
22822317
method: 'HEAD',
2283-
}).finally(() => clearTimeout(timeoutId))
2318+
})
22842319

22852320
tryUpdateEndpointVersionFromResponse(endpoint, response)
22862321

22872322
return response.headers.has('x-github-request-id')
22882323
} catch (e) {
22892324
log.debug(`isGitHubHost: failed with endpoint ${endpoint}`, e)
22902325
return undefined
2326+
} finally {
2327+
clearTimeout(timeoutId)
2328+
clearCertificateErrorSuppressionFor(metaUrl)
22912329
}
22922330
}

app/src/lib/feature-flag.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -81,24 +81,10 @@ export function enablePullRequestQuickView(): boolean {
8181
return enableDevelopmentFeatures()
8282
}
8383

84-
export function enableMoveStash(): boolean {
85-
return true
86-
}
87-
88-
export const enableRepoRulesBeta = () => true
89-
90-
export const enableCommitDetailsHeaderExpansion = () => true
91-
92-
export const enableDiffCheckMarksAndLinkUnderlines = () => true
93-
94-
export const enableDiffCheckMarks = enableDiffCheckMarksAndLinkUnderlines
95-
export const enableGroupDiffCheckmarks = enableDiffCheckMarksAndLinkUnderlines
96-
97-
export const enableLinkUnderlines = enableDiffCheckMarksAndLinkUnderlines
98-
9984
export const enableExternalCredentialHelper = () => true
10085
export const enableCredentialHelperTrampoline = () => true
10186

10287
export const enableCustomIntegration = () => true
10388

10489
export const enableResizingToolbarButtons = enableBetaFeatures
90+
export const enableGitConfigParameters = enableBetaFeatures

app/src/lib/git/core.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export class GitError extends Error {
9898
} else if (result.stdout.length) {
9999
message = result.stdout
100100
} else {
101-
message = 'Unknown error'
101+
message = `Unknown error (exit code ${result.exitCode})`
102102
rawMessage = false
103103
}
104104

@@ -257,7 +257,8 @@ export async function git(
257257
throw new GitError(gitResult, args)
258258
},
259259
path,
260-
options?.isBackgroundTask ?? false
260+
options?.isBackgroundTask ?? false,
261+
options?.env
261262
)
262263
}
263264

app/src/lib/git/diff.ts

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import { spawnAndComplete } from './spawn'
2525

2626
import { DiffParser } from '../diff-parser'
2727
import { getOldPathOrDefault } from '../get-old-path'
28-
import { getCaptures } from '../helpers/regex'
2928
import { readFile } from 'fs/promises'
3029
import { forceUnwrap } from '../fatal-error'
3130
import { git } from './core'
@@ -34,6 +33,8 @@ import { GitError } from 'dugite'
3433
import { IChangesetData, parseRawLogWithNumstat } from './log'
3534
import { getConfigValue } from './config'
3635
import { getMergeBase } from './merge'
36+
import { IStatusEntry } from '../status-parser'
37+
import { createLogParser } from './git-delimiter-parser'
3738

3839
/**
3940
* V8 has a limit on the size of string it can create (~256MB), and unless we want to
@@ -716,20 +717,51 @@ export async function getWorkingDirectoryImage(
716717
*/
717718
export async function getBinaryPaths(
718719
repository: Repository,
719-
ref: string
720+
ref: string,
721+
conflictedFilesInIndex: ReadonlyArray<IStatusEntry>
720722
): Promise<ReadonlyArray<string>> {
723+
const [detectedBinaryFiles, conflictedFilesUsingBinaryMergeDriver] =
724+
await Promise.all([
725+
getDetectedBinaryFiles(repository, ref),
726+
getFilesUsingBinaryMergeDriver(repository, conflictedFilesInIndex),
727+
])
728+
729+
return Array.from(
730+
new Set([...detectedBinaryFiles, ...conflictedFilesUsingBinaryMergeDriver])
731+
)
732+
}
733+
734+
/**
735+
* Runs diff --numstat to get the list of files that have changed and which
736+
* Git have detected as binary files
737+
*/
738+
async function getDetectedBinaryFiles(repository: Repository, ref: string) {
721739
const { output } = await spawnAndComplete(
722740
['diff', '--numstat', '-z', ref],
723741
repository.path,
724742
'getBinaryPaths'
725743
)
726-
const captures = getCaptures(output.toString('utf8'), binaryListRegex)
727-
if (captures.length === 0) {
728-
return []
729-
}
730-
// flatten the list (only does one level deep)
731-
const flatCaptures = captures.reduce((acc, val) => acc.concat(val))
732-
return flatCaptures
744+
745+
return Array.from(output.toString().matchAll(binaryListRegex), m => m[1])
733746
}
734747

735748
const binaryListRegex = /-\t-\t(?:\0.+\0)?([^\0]*)/gi
749+
750+
async function getFilesUsingBinaryMergeDriver(
751+
repository: Repository,
752+
files: ReadonlyArray<IStatusEntry>
753+
) {
754+
const { stdout } = await git(
755+
['check-attr', '--stdin', '-z', 'merge'],
756+
repository.path,
757+
'getConflictedFilesUsingBinaryMergeDriver',
758+
{
759+
stdin: files.map(f => f.path).join('\0'),
760+
}
761+
)
762+
763+
return createLogParser({ path: '', attr: '', value: '' })
764+
.parse(stdout)
765+
.filter(x => x.attr === 'merge' && x.value === 'binary')
766+
.map(x => x.path)
767+
}

app/src/lib/git/rebase.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ export async function rebaseInteractive(
557557
const baseOptions: IGitExecutionOptions = {
558558
expectedErrors: new Set([GitError.RebaseConflicts]),
559559
env: {
560+
GIT_SEQUENCE_EDITOR: undefined,
560561
GIT_EDITOR: gitEditor,
561562
},
562563
}

app/src/lib/git/spawn.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ export const spawnGit = (
4848
})
4949
),
5050
path,
51-
options?.isBackgroundTask ?? false
51+
options?.isBackgroundTask ?? false,
52+
options?.env
5253
)
5354

5455
/**

0 commit comments

Comments
 (0)