Created
December 6, 2017 21:29
-
-
Save christoph-frick/60020755bc749e4d70d6517ec5c51210 to your computer and use it in GitHub Desktop.
Helper to create a pull request for SteamLinux
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
import groovy.json.* | |
def rootbranch = "upstream/master" | |
def jsonFile = "GAMES.json" as File | |
def id = args[0] | |
["git", "checkout", "-b", id, rootbranch].execute() | |
def json = new JsonSlurper().parse(jsonFile) | |
if (json.containsKey(id)) { | |
println "Already added" | |
System.exit(1) | |
} | |
def url = "http://store.steampowered.com/app/$id" | |
def page = url.toURL().text | |
def tm = page =~ /.*<title>(.*) on Steam<\/title>.*/ | |
def message = tm ? "${tm.group(1)} ($id) works" : "$id works" | |
println message | |
if (page.find(/data-os="linux"/)) { | |
println "Indicated to work" | |
} | |
json.put(id, true) | |
jsonFile.text = JsonOutput.prettyPrint( | |
JsonOutput.toJson( | |
json.sort{a,b->a.key.toLong()<=>b.key.toLong()} | |
) | |
).replace(" ", "\t") | |
.replace(": {", ":\n\t{") + "\n" | |
["git", "commit", "-m", message, jsonFile.toString()].execute() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment