Skip to content

Commit

Permalink
Topic support added
Browse files Browse the repository at this point in the history
  • Loading branch information
Colum Paget committed Apr 8, 2019
1 parent 9ee6039 commit 510a55b
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ Available commands are:
githuber.lua repo issues [repo] - list repo issues
githuber.lua repo pulls [repo] - list repo pull requests
githuber.lua repo forks [repo] - list repo forks
githuber.lua repo topics [repo] - list repo topics
githuber.lua repo settopics [repo] [topic] [topic]... - set repo topics, this doesn't add, it sets a new list
githuber.lua preq [repo] [title] - issue a pull request to parent repo
githuber.lua star [url] - 'star' (bookmark) a repo by url
githuber.lua unstar [url] - remove a 'star' (bookmark) of a repo by url
Expand Down
55 changes: 55 additions & 0 deletions githuber.lua
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,12 @@ GithubRepoListForks(user, args[3])
elseif args[2]=="pulls"
then
GithubRepoPulls(user, args[3])
elseif args[2]=="topics"
then
GithubRepoTopics(user, args[3])
elseif args[2]=="settopics"
then
GithubRepoSetTopics(user, args[3], args)
elseif args[2]=="history"
then
GithubRepoCommitsList("history", user, args[3])
Expand Down Expand Up @@ -801,6 +807,7 @@ end

function GithubForkRepo(user, url, WatchType)
local S, doc
local P, items
local URLInfo

URLInfo=net.parseURL(url)
Expand All @@ -810,6 +817,54 @@ GithubPost(url, "", "Fork sucessful", "Fork failed: ")
end


function GithubRepoTopics(user, repo)
local S, doc, url, P, item, items
local Event={}

url="https://"..GithubUser..":"..GithubAuth.."@api.github.com/repos/"..user.."/"..repo.."/topics";
S=stream.STREAM(url, "r Accept=application/vnd.github.mercy-preview+json")
doc=S:readdoc()
print(doc)
P=dataparser.PARSER("json", doc)
items=P:open("/names")

item=items:first()
while item ~= nil
do
Out:puts("item:" .. item:name() .. "\n")
item=items:next()
end

end


function GithubRepoSetTopics(user, repo, args)
local json, url, i, topic
local topics=""


for i,topic in ipairs(args)
do
if i > 3
then
if strutil.strlen(topics)==0
then
topics=topics .. '"' .. topic .. '"'
else
topics=topics .. ', "' .. topic .. '"'
end
end
end


url="https://"..GithubUser..":"..GithubAuth.."@api.github.com/repos/"..user.."/"..repo.."/topics";
json='{"names": [' .. topics .. ']}'

print("JSON: "..json)
GithubPutPost(url, "W Accept=application/vnd.github.mercy-preview+json", json, "topics updated", "failed to set topics")

end



function GithubRepoPulls(user, repo)
Expand Down

0 comments on commit 510a55b

Please sign in to comment.