Add pull requests DCGIs - gophercgis - Collection of gopher CGI/DCGI for geomyidae
(HTM) hg clone https://bitbucket.org/iamleot/gophercgis
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) changeset 55ac27e4ad572f940adae9de63f0c65b276eb483
(DIR) parent f9f35ddcd2cea281e132f06f34908e8be9b5f812
(HTM) Author: Leonardo Taccari <iamleot@gmail.com>
Date: Fri, 31 Aug 2018 14:33:39
Add pull requests DCGIs
Diffstat:
github/pull.dcgi | 46 ++++++++++++++++++++++++++++++++++++++++++++++
github/pulls.dcgi | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 81 insertions(+), 0 deletions(-)
---
diff -r f9f35ddcd2ce -r 55ac27e4ad57 github/pull.dcgi
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/github/pull.dcgi Fri Aug 31 14:33:39 2018 +0200
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+
+ISSUE_CGI="/cgi/github/issue.dcgi"
+ISSUES_CGI="/cgi/github/issues.dcgi"
+COMMITS_CGI="/cgi/github/commits.dcgi"
+PULLS_CGI="/cgi/github/pulls.dcgi"
+PULL_CGI="/cgi/github/pull.dcgi"
+
+
+case "$2" in
+*/*/*)
+ IFS=/ set -- "$2"
+ set -- $*
+ owner=$1
+ repo=$2
+ pull=$3
+ ;;
+*)
+ exit 1
+ ;;
+esac
+
+
+url="https://api.github.com/repos/${owner}/${repo}/pulls/${pull}"
+/usr/pkg/bin/curl -s "${url}" |
+ /usr/pkg/bin/jq -r '
+ "",
+ "GitHub - '"${owner}/${repo}"' pull request #'"${pull}"'",
+ "",
+ "#\(.number) \(.title)",
+ "\(.state) @\(.user.login) \(.created_at[0:10])",
+ "[h|patch|URL:\(.patch_url)|server|port]",
+ "",
+ "\(.body)",
+ ""
+' | expand | sed -e '/^\[[0137Ighi]\|/n' -e 's/^/t/'
+
+url="https://api.github.com/repos/${owner}/${repo}/pulls/${pull}/comments"
+/usr/pkg/bin/curl -s "${url}" |
+ /usr/pkg/bin/jq -r '
+ .[] |
+ "@\(.user.login) writes:",
+ "\(.body)",
+ ""
+' | expand | sed -e '/^\[[0137Ighi]\|/n' -e 's/^/t/'
diff -r f9f35ddcd2ce -r 55ac27e4ad57 github/pulls.dcgi
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/github/pulls.dcgi Fri Aug 31 14:33:39 2018 +0200
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+
+ISSUE_CGI="/cgi/github/issue.dcgi"
+ISSUES_CGI="/cgi/github/issues.dcgi"
+COMMITS_CGI="/cgi/github/commits.dcgi"
+PULLS_CGI="/cgi/github/pulls.dcgi"
+PULL_CGI="/cgi/github/pull.dcgi"
+
+
+case "$2" in
+*/*)
+ owner=${2%%/*}
+ repo=${2##*/}
+ ;;
+*)
+ exit 1
+ ;;
+esac
+
+
+url="https://api.github.com/repos/${owner}/${repo}/pulls"
+/usr/pkg/bin/curl -s "${url}" |
+ /usr/pkg/bin/jq -r '
+ "t",
+ "tGitHub - '"${owner}/${repo}"' pull requests",
+ "t",
+ ( .[] |
+ "[1|#\(.number) \(.title | gsub("\\|"; "\\|"))|" +
+ "'"${PULL_CGI}?${owner}/${repo}/"'\(.number)|server|port]",
+ "t\(.state) @\(.user.login) \(.created_at[0:10])",
+ "[h|patch|URL:\(.patch_url)|server|port]",
+ "t"
+ )
+'