-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathviewbug.js
More file actions
executable file
·50 lines (45 loc) · 1.45 KB
/
viewbug.js
File metadata and controls
executable file
·50 lines (45 loc) · 1.45 KB
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
#!/usr/bin/env node
var https = require('https');
if (process.argv.length >= 3) {
queryBug(process.argv[2]);
} else {
require('child_process').exec('git branch | grep "*" | tail -c 7', function(error, stdout, stderr) {
queryBug(stdout);
});
}
function queryBug(bugNumber) {
console.log('Looking for bug ' + bugNumber + '...\n');
req = https.request('https://bugzilla.mozilla.org/rest/bug/' + bugNumber, function(res) {
var bugData = '';
res.on('data', function(d) {
bugData = bugData + d;
});
res.on('end', function(d) {
if (d) {
bugData = bugData + d;
}
try {
bugData = JSON.parse(bugData);
showBug(bugData);
} catch(e) {
console.log('Error: ' + e);
}
});
});
req.on('error', function(e) {
console.log('Error: ' + e);
});
req.end();
}
function showBug(bugData) {
if (process.argv[3] === '-d') {
console.log(JSON.stringify(bugData.bugs[0],true,' ') + '\n\n');
}
var url = 'http://bugzilla.mozilla.org/' + bugData.bugs[0].id;
console.log('Bug number: ' + bugData.bugs[0].id + ' - ' + url);
console.log('Summary: Bug ' + bugData.bugs[0].id + ' - ' + bugData.bugs[0].summary);
console.log('Status: ' + bugData.bugs[0].status + ' ' + bugData.bugs[0].resolution);
console.log('Assigned to: ' + bugData.bugs[0].assigned_to);
console.log('Created on: ' + bugData.bugs[0].creation_time);
console.log('Changed on: ' + bugData.bugs[0].last_change_time);
}