Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion github.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,33 @@
# description:
# GitHub API Client
#

set -e
set -o pipefail

function get_realpath() {

link="$1"
while [ -L "$link" ]; do
lastLink="$link"
link=$(/bin/ls -ldq "$link")
link="${link##* -> }"
link=$(realpath "$link")
[ "$link" == "$lastlink" ] && >&2 echo -e "ERROR: link loop detected on $link" && return 1 # error
done

echo $link

return 0 # success
}


# include files

. ${BASH_SOURCE[0]%/*}/lib/initializer.sh
BASENAME=$(cd $(dirname "$(get_realpath $0)") && pwd -P)


. ${BASENAME}/lib/initializer.sh

# main

Expand Down
15 changes: 13 additions & 2 deletions lib/v3.d/pulls.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,21 @@

task_list() {
# http://developer.github.com/v3/pulls/#list-pull-requests
local owner=$1 repo=$2
local owner=$1 repo=$2 state=$3 page=$4

call_api -X GET \
"$(base_uri)/repos/${owner}/${repo}/pulls?$(query_string \
$(add_param state string optional) \
$(add_param page string optional) \
)"
}

task_diff() {
# http://developer.github.com/v3/pulls/#get-a-single-pull-request
local owner=$1 repo=$2 number=$3

call_api -X GET \
$(base_uri)/repos/${owner}/${repo}/pulls?state=${state:-open}
$(base_uri)/repos/${owner}/${repo}/pulls/${number}/files
}

task_get() {
Expand Down