This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
digpoe's profile picture

[Question] Would GitHub work with the HTTP api?

Started by digpoe, 09 November 2012 - 06:36 AM
digpoe #1
Posted 09 November 2012 - 07:36 AM
I would like to know if GitHub raw view would work with the HTTP Api if you are trying to make an update program. Would it? It would be helpful if it did, as I don't want to make a Pastebin account with a password I'd probbably forget.
PixelToast #2
Posted 09 November 2012 - 07:39 AM
Yes but you would also need a file to tell you where all the files you need to download are
digpoe #3
Posted 09 November 2012 - 07:41 AM
Yes but you would also need a file to tell you where all the files you need to download are
I meant, if I have a raw view of a file up on GitHub, (it has no formatting to it) would I be able to use it to update a program if it's out of date?
Cloudy #4
Posted 09 November 2012 - 07:55 AM
Yes, the https protocol is supported.
digpoe #5
Posted 09 November 2012 - 08:04 AM
Ok, thanks. But it seems I am getting errors…. Here's my code: https://raw.github.com/DigiTechs/MCstuff/master/updatetest
I don't get why it doesn't work, it should function fine.
The code i'm using in MC is:

local version =
0
function versioncheck()
	    term.clear()
	    term.setCursorPos(1,1)
	    print("Program loading...")
	    print("Current version: "..version)
	    local updateSite = http.get("https://raw.github.com/DigiTechs/Minecraftstuff/6bcf62fd71421eb5182605068f93c228f78b172b/updatetest")
	    local coding = updateSite.readLine(2)
	    local newVersion = (tonumber(coding))
	    sleep(2)
	    if tonumber(newVersion) > version then
			    print("Newest version is: "..newVersion)
			    print("Update required. Updating now...")
			    local updateSite = http.get("https://raw.github.com/DigiTechs/Minecraftstuff/6bcf62fd71421eb5182605068f93c228f78b172b/updatetest")
			    local siteFile = updateSite.readAll()
			    local writeFile = fs.open(shell.getRunningProgram(),"w")
			    writeFile.write(siteFile)
			    writeFile.close()
			    print("The program will now restart your computer.")
			    sleep(2)
			    os.reboot()
	    end
end
Sammich Lord #6
Posted 09 November 2012 - 08:44 AM
Please post a error log. Are you trying to pull a commit or what? Or do you have a folder named "6bcf62fd71421eb5182605068f93c228f78b172b"?
Lyqyd #7
Posted 09 November 2012 - 08:45 AM
What version of ComputerCraft are you using?
digpoe #8
Posted 09 November 2012 - 09:04 AM
What version of ComputerCraft are you using?
It's 1.46 according to MultiMC's console.
digpoe #9
Posted 09 November 2012 - 09:05 AM
Please post a error log. Are you trying to pull a commit or what? Or do you have a folder named "6bcf62fd71421eb5182605068f93c228f78b172b"?

I'm getting no errors from the game, it just runs and "does nothing" - The actual link to get to the raw file is https://raw.github.com/DigiTechs/Minecraftstuff/6bcf62fd71421eb5182605068f93c228f78b172b/updatetest - and I belive the 6bdcf thing is just the commit info.
Kolpa #10
Posted 09 November 2012 - 09:13 AM
https://github.com/K...o%20updater.lua
there ya go

this pretty much downloads everything