Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3511884
D4689.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D4689.diff
View Options
diff --git a/scripts/generate-phab-tag-removal-script.js b/scripts/generate-phab-tag-removal-script.js
new file mode 100755
--- /dev/null
+++ b/scripts/generate-phab-tag-removal-script.js
@@ -0,0 +1,60 @@
+// @flow
+
+const fs = require('fs');
+const { request } = require('gaxios');
+
+const PHABRICATOR_API_TOKEN = process.env.PHABRICATOR_API_TOKEN;
+if (!PHABRICATOR_API_TOKEN) {
+ console.log('ERROR: Unable to retrieve PHABRICATOR_API_TOKEN.');
+ process.exit(1);
+}
+
+const getDifferentialDataFromPhabricator = async () => {
+ return await request({
+ url: 'https://phab.comm.dev/api/differential.query',
+ params: {
+ 'api.token': PHABRICATOR_API_TOKEN,
+ },
+ });
+};
+
+const getRevisionsToBeRemoved = differentialData => {
+ const revisionsToBeRemoved = [];
+ for (const diff of differentialData.data['result']) {
+ if (
+ diff['statusName'] === 'Abandonded' ||
+ diff['statusName'] === 'Closed'
+ ) {
+ revisionsToBeRemoved.push(...diff['diffs']);
+ }
+ }
+ return revisionsToBeRemoved;
+};
+
+const getGitTagsToBeRemoved = revisionsToBeRemoved => {
+ const gitTagsToBeRemoved = [];
+ for (const revisionID of revisionsToBeRemoved) {
+ gitTagsToBeRemoved.push(`phabricator/base/${revisionID}`);
+ gitTagsToBeRemoved.push(`phabricator/diff/${revisionID}`);
+ }
+ return gitTagsToBeRemoved;
+};
+
+const getGitCommandsToBeRun = gitTagsToBeRemoved => {
+ return gitTagsToBeRemoved.map(tag => `git push --delete origin tag ${tag}`);
+};
+
+const writeGitCommandsScriptToDisk = gitCommandsToBeRun => {
+ fs.writeFileSync('tag_removal_script.sh', gitCommandsToBeRun.join('\n'));
+};
+
+async function main() {
+ const differentialData = await getDifferentialDataFromPhabricator();
+ const revisionsToBeRemoved = getRevisionsToBeRemoved(differentialData);
+ const gitTagsToBeRemoved = getGitTagsToBeRemoved(revisionsToBeRemoved);
+ const gitCommandsToBeRun = getGitCommandsToBeRun(gitTagsToBeRemoved);
+ writeGitCommandsScriptToDisk(gitCommandsToBeRun);
+ process.exit(0);
+}
+
+main();
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 22, 5:12 PM (17 h, 42 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2691948
Default Alt Text
D4689.diff (2 KB)
Attached To
Mode
D4689: [CI] Introduce Harbormaster tag removal script generator
Attached
Detach File
Event Timeline
Log In to Comment