summarylogtreecommitdiffstats
path: root/powercord-updater.patch
blob: 7c28cb5a1fb8a61770a9e359efeef582276bfb2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
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.POWERCORD_UPDATES_UPSTREAM}</span>
-            <span>{powercord.gitInfos.upstream.replace(REPO_URL, Messages.POWERCORD_UPDATES_UPSTREAM_OFFICIAL)}</span>
+            <span>{powercord.gitInfos.upstream.replace(REPO_URL, Messages.POWERCORD_UPDATES_UPSTREAM_OFFICIAL+' (AUR)')}</span>
           </div>
           <div>
             <span>{Messages.POWERCORD_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@"
     };
   }