-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Script that shows pending presubmit branches that need attention such as manual merge.
- Loading branch information
Showing
2 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
# Shows a list of pending presubmit branches that have not been merged. | ||
# These branches need manual attention. | ||
|
||
# Fetch all the upstream branches. | ||
git fetch upstream | ||
|
||
# List all upstream/presubmit-* branches that have not been merged into upstream/master neither upstream/canary yet. | ||
BRANCHES=$(comm -12 <(git branch -r --no-merged upstream/master) <(git branch -r --no-merged upstream/canary) | egrep "^\s*upstream/presubmit-" | sed "s# upstream/##") | ||
|
||
# Print Travis status of all these branches. | ||
./scripts/print_travis_status.js "karma-runner/karma" "$BRANCHES" "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/usr/bin/env node | ||
'use strict'; | ||
|
||
var http = require('https'); | ||
|
||
var COLORS = { | ||
green : ['\x1B[32m', '\x1B[39m'], | ||
red : ['\x1B[31m', '\x1B[39m'] | ||
}; | ||
|
||
var repo = process.argv[2]; | ||
var branches = process.argv[3]; | ||
|
||
if (!branches) { | ||
console.log('No pending branches.'); | ||
process.exit(0); | ||
} | ||
|
||
branches = branches.split('\n'); | ||
|
||
var options = { | ||
hostname: 'api.travis-ci.org', | ||
headers: { | ||
'User-Agent': 'Vojta/0.0.1', | ||
'Accept': 'application/vnd.travis-ci.2+json' | ||
} | ||
}; | ||
|
||
function red(str) { | ||
return COLORS.red[0] + str + COLORS.red[1]; | ||
} | ||
|
||
function green(str) { | ||
return COLORS.green[0] + str + COLORS.green[1]; | ||
} | ||
|
||
function bufferJsonStream(stream, done) { | ||
var buffer = ''; | ||
|
||
stream.on('data', function(data) { | ||
buffer += data.toString(); | ||
}); | ||
|
||
stream.on('end', function() { | ||
done(JSON.parse(buffer)); | ||
}); | ||
} | ||
|
||
branches.forEach(function(branch) { | ||
options.path = '/repos/' + repo + '/branches/' + branch; | ||
|
||
http.get(options, function(response) { | ||
bufferJsonStream(response, function(resp) { | ||
|
||
console.log('Branch: ' + branch); | ||
console.log(' https://github.com/' + repo + '/tree/' + branch); | ||
|
||
if (response.headers.status === '404 Not Found') { | ||
console.log(red('Travis: NOT FOUND')); | ||
} else { | ||
switch (resp.branch.state) { | ||
case 'passed': | ||
console.log(green('Travis: ' + resp.branch.state + ' (' + resp.branch.finished_at + ')')); | ||
break; | ||
case 'failed': | ||
console.log(red('Travis: ' + resp.branch.state + ' (' + resp.branch.finished_at + ')')); | ||
break; | ||
case 'started': | ||
console.log('Travis: ' + resp.branch.state + ' (' + resp.branch.started_at + ')'); | ||
break; | ||
default: | ||
console.log('Travis: ' + resp.branch.state); | ||
} | ||
console.log(' https://travis-ci.org/' + repo + '/builds/' + resp.branch.id); | ||
} | ||
|
||
console.log(''); | ||
}); | ||
}); | ||
}); |