diff options
author | Łukasz Mariański | 2022-08-08 06:11:18 +0200 |
---|---|---|
committer | Łukasz Mariański | 2022-08-08 06:12:14 +0200 |
commit | e285006defdae43108cae721632f36adf7c8cdc8 (patch) | |
tree | a929baed33aa9b3d5bf94ae8b8f5f503bf975173 /replugged-updater.patch | |
download | aur-e285006defdae43108cae721632f36adf7c8cdc8.tar.gz |
Initial commit, (mostly) copied over from powercord-electron-git
Diffstat (limited to 'replugged-updater.patch')
-rw-r--r-- | replugged-updater.patch | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/replugged-updater.patch b/replugged-updater.patch new file mode 100644 index 000000000000..64e6880581f1 --- /dev/null +++ b/replugged-updater.patch @@ -0,0 +1,113 @@ +diff --git a/src/Powercord/index.js b/src/Powercord/index.js +index edcecb5f..5f810080 100644 +--- a/src/Powercord/index.js ++++ b/src/Powercord/index.js +@@ -244,6 +244,32 @@ class Powercord extends Updatable { + } + return success; + } ++ ++ async _getUpdateCommits () { ++ return []; ++ } ++ async getBranch () {return this.gitInfos.branch;} ++ async getGitRepo () {return this.gitInfos.upstream;} ++ async _checkForUpdates () { ++ const abort = new AbortController(); ++ const timeout = setTimeout(() => { ++ abort.abort(); ++ throw new Error('Timed out.'); ++ }, 10000); ++ ++ try { ++ const latestCommitSha = await exec(`curl https://api.github.com/repos/${this.gitInfos.upstream}/commits/${this.gitInfos.branch} | jq -r .sha`, { ++ cwd: this.entityPath, ++ signal: abort.signal ++ }).then(({ stdout }) => stdout.toString()); ++ ++ clearTimeout(timeout); ++ return !latestCommitSha.includes(this.gitInfos.revision); ++ } catch (e) { ++ clearTimeout(timeout); ++ return false; ++ } ++ } + } + + module.exports = Powercord; +diff --git a/src/Powercord/plugins/pc-updater/components/Settings.jsx b/src/Powercord/plugins/pc-updater/components/Settings.jsx +index a1b8b9b3..eb1cbd4a 100644 +--- a/src/Powercord/plugins/pc-updater/components/Settings.jsx ++++ b/src/Powercord/plugins/pc-updater/components/Settings.jsx +@@ -83,7 +83,7 @@ module.exports = class UpdaterSettings extends React.PureComponent { + <div className="about"> + <div> + <span>{Messages.REPLUGGED_UPDATES_UPSTREAM}</span> +- <span>{powercord.gitInfos.upstream.replace(REPO_URL, Messages.REPLUGGED_UPDATES_UPSTREAM_OFFICIAL)}</span> ++ <span>{powercord.gitInfos.upstream.replace(REPO_URL, Messages.REPLUGGED_UPDATES_UPSTREAM_OFFICIAL+' (AUR)')}</span> + </div> + <div> + <span>{Messages.REPLUGGED_UPDATES_REVISION}</span> +diff --git a/src/Powercord/plugins/pc-updater/components/Update.jsx b/src/Powercord/plugins/pc-updater/components/Update.jsx +index d2d9fb79..337e158f 100644 +--- a/src/Powercord/plugins/pc-updater/components/Update.jsx ++++ b/src/Powercord/plugins/pc-updater/components/Update.jsx +@@ -33,6 +33,7 @@ module.exports = class Update extends React.PureComponent { + </div> + </div> + <div className='summary'> ++ {name === 'Powercord' ? <span>Note: Please download the update from the AUR!</span> : ''} + {commits.map(commit => <div key={commit.id}> + <a href={`https://github.com/${repo}/commit/${commit.id}`} target='_blank'> + <code>{commit.id.substring(0, 7)}</code> +diff --git a/src/Powercord/plugins/pc-updater/index.js b/src/Powercord/plugins/pc-updater/index.js +index e445159e..23a74241 100644 +--- a/src/Powercord/plugins/pc-updater/index.js ++++ b/src/Powercord/plugins/pc-updater/index.js +@@ -147,14 +147,14 @@ module.exports = class Updater extends Plugin { + const updates = this.settings.get('updates', []); + const failed = []; + for (const update of [ ...updates ]) { +- let entity = powercord; ++ let entity; + if (update.id.startsWith('plugin')) { + entity = powercord.pluginManager.get(update.id.replace('plugins_', '')); + } else if (update.id.startsWith('theme')) { + entity = powercord.styleManager.get(update.id.replace('themes_', '')); + } + +- const success = await entity._update(force); ++ const success = entity ? await entity._update(force) : false; + updates.shift(); + this.settings.get('updates', updates); + if (!success) { +@@ -243,26 +243,10 @@ module.exports = class Updater extends Plugin { + } + + async getGitInfos () { +- const branch = await PowercordNative.exec('git branch', this.cwd) +- .then(({ stdout }) => +- stdout +- .toString() +- .split('\n') +- .find(l => l.startsWith('*')) +- .slice(2) +- .trim() +- ); +- +- const revision = await PowercordNative.exec(`git rev-parse ${branch}`, this.cwd) +- .then(r => r.stdout.toString().trim()); +- +- const upstream = await PowercordNative.exec('git remote get-url origin', this.cwd) +- .then(r => r.stdout.toString().match(/github\.com[:/]([\w-_]+\/[\w-_]+)/)[1]); +- + return { +- upstream, +- branch, +- revision ++ upstream: "@PKG_UPSTREAM@", ++ branch: "@PKG_BRANCH@", ++ revision: "@PKG_REVISION@" + }; + } + |