Merge pull request #14883 from desktop/force-non-staggered-updates

Allow bypassing staggered releases
This commit is contained in:
Sergio Padrino 2022-08-22 16:28:35 +02:00 committed by GitHub
commit 4189cc8914
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 56 additions and 8 deletions

View file

@ -47,6 +47,9 @@ interface IAboutProps {
/** A function to call to kick off an update check. */
readonly onCheckForUpdates: () => void
/** A function to call to kick off a non-staggered update check. */
readonly onCheckForNonStaggeredUpdates: () => void
readonly onShowAcknowledgements: () => void
/** A function to call when the user wants to see Terms and Conditions. */
@ -55,6 +58,7 @@ interface IAboutProps {
interface IAboutState {
readonly updateState: IUpdateState
readonly altKeyPressed: boolean
}
/**
@ -69,6 +73,7 @@ export class About extends React.Component<IAboutProps, IAboutState> {
this.state = {
updateState: updateStore.state,
altKeyPressed: false,
}
}
@ -81,6 +86,8 @@ export class About extends React.Component<IAboutProps, IAboutState> {
this.onUpdateStateChanged
)
this.setState({ updateState: updateStore.state })
window.addEventListener('keydown', this.onKeyDown)
window.addEventListener('keyup', this.onKeyUp)
}
public componentWillUnmount() {
@ -88,6 +95,20 @@ export class About extends React.Component<IAboutProps, IAboutState> {
this.updateStoreEventHandle.dispose()
this.updateStoreEventHandle = null
}
window.removeEventListener('keydown', this.onKeyDown)
window.removeEventListener('keyup', this.onKeyUp)
}
private onKeyDown = (event: KeyboardEvent) => {
if (event.key === 'Alt') {
this.setState({ altKeyPressed: true })
}
}
private onKeyUp = (event: KeyboardEvent) => {
if (event.key === 'Alt') {
this.setState({ altKeyPressed: false })
}
}
private onQuitAndInstall = () => {
@ -119,10 +140,22 @@ export class About extends React.Component<IAboutProps, IAboutState> {
UpdateStatus.UpdateNotAvailable,
].includes(updateStatus)
const onClick = this.state.altKeyPressed
? this.props.onCheckForNonStaggeredUpdates
: this.props.onCheckForUpdates
const buttonTitle = this.state.altKeyPressed
? 'Ensure Latest Version'
: 'Check for Updates'
const tooltip = this.state.altKeyPressed
? "GitHub Desktop may release updates to our user base gradually to ensure we catch any problems early. This lets you bypass the gradual rollout and jump straight to the latest version if there's one available."
: ''
return (
<Row>
<Button disabled={disabled} onClick={this.props.onCheckForUpdates}>
Check for Updates
<Button disabled={disabled} onClick={onClick} tooltip={tooltip}>
{buttonTitle}
</Button>
</Row>
)

View file

@ -615,12 +615,15 @@ export class App extends React.Component<IAppProps, IAppState> {
this.props.dispatcher.setCommitMessageFocus(true)
}
private checkForUpdates(inBackground: boolean) {
private checkForUpdates(
inBackground: boolean,
skipGuidCheck: boolean = false
) {
if (__LINUX__ || __RELEASE_CHANNEL__ === 'development') {
return
}
updateStore.checkForUpdates(inBackground)
updateStore.checkForUpdates(inBackground, skipGuidCheck)
}
private getDotComAccount(): Account | null {
@ -1607,6 +1610,7 @@ export class App extends React.Component<IAppProps, IAppState> {
applicationVersion={version}
applicationArchitecture={process.arch}
onCheckForUpdates={this.onCheckForUpdates}
onCheckForNonStaggeredUpdates={this.onCheckForNonStaggeredUpdates}
onShowAcknowledgements={this.showAcknowledgements}
onShowTermsAndConditions={this.showTermsAndConditions}
/>
@ -2320,6 +2324,8 @@ export class App extends React.Component<IAppProps, IAppState> {
}
private onCheckForUpdates = () => this.checkForUpdates(false)
private onCheckForNonStaggeredUpdates = () =>
this.checkForUpdates(false, true)
private showAcknowledgements = () => {
this.props.dispatcher.showPopup({ type: PopupType.Acknowledgements })

View file

@ -167,10 +167,13 @@ class UpdateStore {
/**
* Check for updates.
*
* @param inBackground - Are we checking for updates in the background, or was
* @param inBackground - Are we checking for updates in the background, or was
* this check user-initiated?
* @param skipGuidCheck - If true, don't check the GUID. If true, this will
* effectively disable the staggered releases system and
* attempt to retrieve the latest available deployment.
*/
public async checkForUpdates(inBackground: boolean) {
public async checkForUpdates(inBackground: boolean, skipGuidCheck: boolean) {
// An update has been downloaded and the app is waiting to be restarted.
// Checking for updates again may result in the running app being nuked
// when it finds a subsequent update.
@ -178,7 +181,7 @@ class UpdateStore {
return
}
const updatesUrl = await this.getUpdatesUrl()
const updatesUrl = await this.getUpdatesUrl(skipGuidCheck)
if (updatesUrl === null) {
return
@ -193,7 +196,7 @@ class UpdateStore {
}
}
private async getUpdatesUrl() {
private async getUpdatesUrl(skipGuidCheck: boolean) {
let url = null
try {
@ -206,6 +209,12 @@ class UpdateStore {
// Send the GUID to the update server for staggered release support
url.searchParams.set('guid', await getRendererGUID())
if (skipGuidCheck) {
// This will effectively disable the staggered releases system and attempt
// to retrieve the latest available deployment.
url.searchParams.set('skipGuidCheck', '1')
}
// If the app is running under arm64 to x64 translation, we need to tweak the
// update URL here to point at the arm64 binary.
if (