Skip to content

Instantly share code, notes, and snippets.

@christoph-frick
Created December 6, 2017 21:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christoph-frick/60020755bc749e4d70d6517ec5c51210 to your computer and use it in GitHub Desktop.
Save christoph-frick/60020755bc749e4d70d6517ec5c51210 to your computer and use it in GitHub Desktop.
Helper to create a pull request for SteamLinux
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