ok.sh

授权协议 BSD-3-Clause License
开发语言 SHELL
所属分类 应用工具、 终端/远程登录
软件类型 开源软件
地区 不详
投 递 者 罗心思
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

A GitHub API client library written in POSIX sh

https://github.com/whiteinge/ok.shBSD licensed.

Requirements

  • A POSIX environment (tested against Busybox v1.19.4)
  • curl (tested against 7.32.0)

Optional requirements

  • jq http://stedolan.github.io/jq/ (tested against 1.3)If jq is not installed commands will output raw JSON; if jq is installedthe output will be formatted and filtered for use with other shell tools.

Setup

Authentication credentials are read from a $HOME/.netrc file on UNIXmachines or a _netrc file in %HOME% for UNIX environments under Windows.Generate the token on GitHub under"Account Settings -> Applications".Restrict permissions on that file with chmod 600 ~/.netrc!

machine api.github.com
    login <username>
    password <token>

machine uploads.github.com
    login <username>
    password <token>

Or set an environment GITHUB_TOKEN=token

Configuration

The following environment variables may be set to customize ok.sh.

  • OK_SH_URL=https://api.github.comBase URL for GitHub or GitHub Enterprise.
  • OK_SH_ACCEPT=application/vnd.github.v3+jsonThe 'Accept' header to send with each request.
  • OK_SH_JQ_BIN=jqThe name of the jq binary, if installed.
  • OK_SH_VERBOSE=0The debug logging verbosity level. Same as the verbose flag.
  • OK_SH_RATE_LIMIT=0Output current GitHub rate limit information to stderr.
  • OK_SH_DESTRUCTIVE=0Allow destructive operations without prompting for confirmation.
  • OK_SH_MARKDOWN=1Output some text in Markdown format.

Usage

ok.sh [<flags>] (command [<arg>, <name=value>...])

ok.sh -h              # Short, usage help text.
ok.sh help            # All help text. Warning: long!
ok.sh help command    # Command-specific help text.
ok.sh command         # Run a command with and without args.
ok.sh command foo bar baz=Baz qux='Qux arg here'
Flag Description
-V Show version.
-h Show this screen.
-j Output raw JSON; don't process with jq.
-q Quiet; don't print to stdout.
-r Print current GitHub API rate limit to stderr.
-v Logging output; specify multiple times: info, debug, trace.
-x Enable xtrace debug logging.
-y Answer 'yes' to any prompts.

Flags must be the first argument to ok.sh, before command.

Table of Contents

Utility and request/response commands

GitHub commands

Commands

_all_funcs

List all functions found in the current file in the order they appear

Keyword arguments

  • public=1

    0 do not output public functions.

  • private=1

    0 do not output private functions.

_log

A lightweight logging system based on file descriptors

Usage:

_log debug 'Starting the combobulator!'

Positional arguments

  • level="$1"

    The level for a given log message. (info or debug)

  • message="$2"

    The log message.

_helptext

Extract contiguous lines of comments and function params as help text

Indentation will be ignored. She-bangs will be ignored. Local variabledeclarations and their default values can also be pulled in asdocumentation. Exits upon encountering the first blank line.

Exported environment variables can be used for string interpolation inthe extracted commented text.

Input

  • (stdin)The text of a function body to parse.

_format_json

Create formatted JSON from name=value pairs

Usage:

ok.sh _format_json foo=Foo bar=123 baz=true qux=Qux=Qux quux='Multi-line
string' quuz=\'5.20170918\' \
  corge="$(ok.sh _format_json grault=Grault)" \
  garply="$(ok.sh _format_json -a waldo true 3)"

Return:

{
  "garply": [
    "waldo",
    true,
    3
  ],
  "foo": "Foo",
  "corge": {
    "grault": "Grault"
  },
  "baz": true,
  "qux": "Qux=Qux",
  "quux": "Multi-line\nstring",
  "quuz": "5.20170918",
  "bar": 123
}

Tries not to quote numbers, booleans, nulls, or nested structures.Note, nested structures must be quoted since the output contains spaces.

The -a option will create an array instead of an object. This optionmust come directly after the _format_json command and before anyoperands. E.g., _format_json -a foo bar baz.

If jq is installed it will also validate the output.

Positional arguments

  • $1 - $9

    Each positional arg must be in the format of name=value which will beadded to a single, flat JSON object.

_format_urlencode

URL encode and join name=value pairs

Usage:

_format_urlencode foo='Foo Foo' bar='<Bar>&/Bar/'

Return:

foo=Foo%20Foo&bar=%3CBar%3E%26%2FBar%2F

Ignores pairs if the value begins with an underscore.

_filter_json

Filter JSON input using jq; outputs raw JSON if jq is not installed

Usage:

printf '[{"foo": "One"}, {"foo": "Two"}]' | \
    ok.sh _filter_json '.[] | "\(.foo)"'
  • (stdin)JSON input.

  • _filter="$1"

    A string of jq filters to apply to the input stream.

_get_mime_type

Guess the mime type for a file based on the file extension

Usage:

local mime_type
_get_mime_type "foo.tar"; printf 'mime is: %s' "$mime_type"

Sets the global variable mime_type with the result. (If this functionis called from within a function that has declared a local variable ofthat name it will update the local copy and not set a global.)

Positional arguments

  • filename="$1"

    The full name of the file, with extension.

_get_confirm

Prompt the user for confirmation

Usage:

local confirm; _get_confirm
[ "$confirm" -eq 1 ] && printf 'Good to go!\n'

If global confirmation is set via $OK_SH_DESTRUCTIVE then the useris not prompted. Assigns the user's confirmation to the confirm globalvariable. (If this function is called within a function that has a localvariable of that name, the local variable will be updated instead.)

Positional arguments

  • message="$1"

    The message to prompt the user with.

_opts_filter

Extract common jq filter keyword options and assign to vars

Usage:

local filter
_opts_filter "$@"

_opts_pagination

Extract common pagination keyword options and assign to vars

Usage:

local _follow_next
_opts_pagination "$@"

_opts_qs

Extract common query string keyword options and assign to vars

Usage:

local qs
_opts_qs "$@"
_get "/some/path"

_request

A wrapper around making HTTP requests with curl

Usage:

# Get JSON for all issues:
_request /repos/saltstack/salt/issues

# Send a POST request; parse response using jq:
printf '{"title": "%s", "body": "%s"}\n' "Stuff" "Things" \
  | _request /some/path | jq -r '.[url]'

# Send a PUT request; parse response using jq:
printf '{"title": "%s", "body": "%s"}\n' "Stuff" "Things" \
  | _request /repos/:owner/:repo/issues method=PUT | jq -r '.[url]'

# Send a conditional-GET request:
_request /users etag=edd3a0d38d8c329d3ccc6575f17a76bb

Input

  • (stdin)Data that will be used as the request body.

Positional arguments

  • path="$1"

    The URL path for the HTTP request.Must be an absolute path that starts with a / or a full URL thatstarts with http(s). Absolute paths will be append to the value in$OK_SH_URL.

Keyword arguments

  • method='GET'

    The method to use for the HTTP request.

  • content_type='application/json'

    The value of the Content-Type header to use for the request.

  • etag

    An optional Etag to send as the If-None-Match header.

_response

Process an HTTP response from curl

Output only headers of interest followed by the response body. Additionalprocessing is performed on select headers to make them easier to parseusing shell tools.

Usage:

# Send a request; output the response and only select response headers:
_request /some/path | _response status_code ETag Link_next

# Make request using curl; output response with select response headers;
# assign response headers to local variables:
curl -isS example.com/some/path | _response status_code status_text | {
  local status_code status_text
  read -r status_code
  read -r status_text
}

Header reformatting

  • HTTP Status

    The HTTP line is split into separate http_version, status_code, andstatus_text variables.

  • ETag

    The surrounding quotes are removed.

  • Link

    Each URL in the Link header is expanded with the URL type appended tothe name. E.g., Link_first, Link_last, Link_next.

Positional arguments

  • $1 - $9

    Each positional arg is the name of an HTTP header. Each header value isoutput in the same order as each argument; each on a single line. Ablank line is output for headers that cannot be found.

_get

A wrapper around _request() for common GET patterns

Will automatically follow 'next' pagination URLs in the Link header.

Usage:

_get /some/path
_get /some/path _follow_next=0
_get /some/path _follow_next_limit=200 | jq -c .

Positional arguments

  • path="$1"

    The HTTP path or URL to pass to _request().

Keyword arguments

  • _follow_next=1

    Automatically look for a 'Links' header and follow any 'next' URLs.

  • _follow_next_limit=50

    Maximum number of 'next' URLs to follow before stopping.

_post

A wrapper around _request() for common POST / PUT patterns

Usage:

_format_json foo=Foo bar=Bar | _post /some/path
_format_json foo=Foo bar=Bar | _post /some/path method='PUT'
_post /some/path filename=somearchive.tar
_post /some/path filename=somearchive.tar mime_type=application/x-tar
_post /some/path filename=somearchive.tar \
  mime_type=$(file -b --mime-type somearchive.tar)

Input

  • (stdin)Optional. See the filename argument also.Data that will be used as the request body.

Positional arguments

  • path="$1"

    The HTTP path or URL to pass to _request().

Keyword arguments

  • method='POST'

    The method to use for the HTTP request.

  • filename

    Optional. See the stdin option above also.Takes precedence over any data passed as stdin and loads a file off thefile system to serve as the request body.

  • mime_type

    The value of the Content-Type header to use for the request.If the filename argument is given this value will be guessed from thefile extension. If the filename argument is not given (i.e., usingstdin) this value defaults to application/json. Specifying thisargument overrides all other defaults or guesses.

_delete

A wrapper around _request() for common DELETE patterns

Usage:

_delete '/some/url'

Return: 0 for success; 1 for failure.

Positional arguments

  • url="$1"

    The URL to send the DELETE request to.

help

Output the help text for a command

Usage:

help commandname

Positional arguments

  • fname="$1"

    Function name to search for; if omitted searches whole file.

show_scopes

Show the permission scopes for the currently authenticated user

Usage:

show_scopes

org_repos

List organization repositories

Usage:

org_repos myorg
org_repos myorg type=private per_page=10
org_repos myorg _filter='.[] | "\(.name)\t\(.owner.login)"'

Positional arguments

  • org="$1"

    Organization GitHub login or id for which to list repos.

Keyword arguments

  • _follow_next

    Automatically look for a 'Links' header and follow any 'next' URLs.

  • _follow_next_limit

    Maximum number of 'next' URLs to follow before stopping.

  • _filter='.[] | "\(.name)\t\(.ssh_url)"'

    A jq filter to apply to the return data.

Querystring arguments may also be passed as keyword arguments:

  • per_page
  • type

org_teams

List teams

Usage:

org_teams org

Positional arguments

  • org="$1"

    Organization GitHub login or id.

Keyword arguments

  • _filter='.[] | "\(.name)\t\(.id)\t\(.permission)"'

    A jq filter to apply to the return data.

org_members

List organization members

Usage:

org_members org

Positional arguments

  • org="$1"

    Organization GitHub login or id.

Keyword arguments

  • _filter='.[] | "\(.login)\t\(.id)"'

    A jq filter to apply to the return data.

org_collaborators

List organization outside collaborators

Usage:

org_collaborators org

Positional arguments

  • org="$1"

    Organization GitHub login or id.

Keyword arguments

  • _filter='.[] | "\(.login)\t\(.id)"'

    A jq filter to apply to the return data.

org_auditlog

Interact with the Github Audit Log

Usage:

org_auditlog org

Positional arguments

  • org="$1"

    Organization GitHub login or id.

Keyword arguments

  • _filter='.[] | "\(.actor)\t\(.action)"'

    A jq filter to apply to the return data.

team_members

List team members

Usage:

team_members team_id

Positional arguments

  • team_id="$1"

    Team id.

Keyword arguments

  • _filter='.[] | "\(.login)\t\(.id)"'

    A jq filter to apply to the return data.

list_repos

List user repositories

Usage:

list_repos
list_repos user

Positional arguments

  • user="$1"

    Optional GitHub user login or id for which to list repos.

Keyword arguments

  • _filter='.[] | "\(.name)\t\(.html_url)"'

    A jq filter to apply to the return data.

Querystring arguments may also be passed as keyword arguments:

  • direction
  • per_page
  • sort
  • type

list_branches

List branches of a specified repository.( https://developer.github.com/v3/repos/#list_branches )

Usage:

list_branches user repo

Positional arguments

GitHub user login or id for which to list branchesName of the repo for which to list branches

  • user="$1"

  • repo="$2"

Keyword arguments

  • _filter='.[] | "\(.name)"'

    A jq filter to apply to the return data.

Querystring arguments may also be passed as keyword arguments:

  • direction
  • per_page
  • sort
  • type

list_commits

List commits of a specified repository.( https://developer.github.com/v3/repos/commits/#list-commits-on-a-repository )

Usage:

list_commits user repo

Positional arguments

GitHub user login or id for which to list branchesName of the repo for which to list branches

list_contributors

List contributors to the specified repository, sorted by the number of commits per contributor in descending order.( https://developer.github.com/v3/repos/#list-contributors )

Usage:

list_contributors user repo

Positional arguments

  • user="$1"

    GitHub user login or id for which to list contributors

  • repo="$2"

    Name of the repo for which to list contributors

Keyword arguments

  • _filter='.[] | "\(.login)\t\(.type)\tType:\(.type)\tContributions:\(.contributions)"'

    A jq filter to apply to the return data.

Querystring arguments may also be passed as keyword arguments:

  • direction
  • per_page
  • sort
  • type

list_collaborators

List collaborators to the specified repository, sorted by the number of commits per collaborator in descending order.( https://developer.github.com/v3/repos/#list-collaborators )

Usage:

list_collaborators someuser/somerepo

Positional argumentsGitHub user login or id for which to list collaboratorsName of the repo for which to list collaborators

  • repo="$1"

Keyword arguments

  • _filter='.[] | "\(.login)\t\(.type)\tType:\(.type)\tPermissions:\(.permissions)"'

    A jq filter to apply to the return data.

Querystring arguments may also be passed as keyword arguments:

  • direction
  • per_page
  • sort
  • type

list_hooks

List webhooks from the specified repository.( https://developer.github.com/v3/repos/hooks/#list-hooks )

Usage:

list_hooks owner/repo

Positional arguments

  • repo="$1"

    Name of the repo for which to list contributorsOwner is mandatory, like 'owner/repo'

  • _filter='.[] | "\(.name)\t\(.config.url)"'

    A jq filter to apply to the return data.

list_gists

List gists for the current authenticated user or a specific user

https://developer.github.com/v3/gists/#list-a-users-gists

Usage:

list_gists
list_gists <username>

Positional arguments

  • username="$1"

    An optional user to filter listing

Keyword arguments

  • _follow_next

    Automatically look for a 'Links' header and follow any 'next' URLs.

  • _follow_next_limit

    Maximum number of 'next' URLs to follow before stopping.

  • _filter='.[] | "\(.id)\t\(.description)"'

    A jq filter to apply to the return data.

public_gists

List public gists

https://developer.github.com/v3/gists/#list-all-public-gists

Usage:

public_gists

Keyword arguments

  • _follow_next

    Automatically look for a 'Links' header and follow any 'next' URLs.

  • _follow_next_limit

    Maximum number of 'next' URLs to follow before stopping.

  • _filter='.[] | "\(.id)\t\(.description)"'

    A jq filter to apply to the return data.

gist

Get a single gist

https://developer.github.com/v3/gists/#get-a-single-gist

Usage:

get_gist

Positional arguments

  • gist_id="$1"

    ID of gist to fetch.

Keyword arguments

  • _filter='.files | keys | join(", ")'

    A jq filter to apply to the return data.

add_collaborator

Add a collaborator to a repository

Usage:

add_collaborator someuser/somerepo collaboratoruser permission

Positional arguments

  • repo="$1"

    A GitHub repository.

  • collaborator="$2"

    A new collaborator.

  • permission="$3"

    The permission level for this collaborator. One of push, pull,admin. The pull and admin permissions are valid for organizationrepos only.

Keyword arguments

  • _filter='"\(.name)\t\(.color)"'

    A jq filter to apply to the return data.

delete_collaborator

Delete a collaborator to a repository

Usage:

delete_collaborator someuser/somerepo collaboratoruser permission

Positional arguments

  • repo="$1"

    A GitHub repository.

  • collaborator="$2"

    A new collaborator.

create_repo

Create a repository for a user or organization

Usage:

create_repo foo
create_repo bar description='Stuff and things' homepage='example.com'
create_repo baz organization=myorg

Positional arguments

  • name="$1"

    Name of the new repo

Keyword arguments

  • _filter='"\(.name)\t\(.html_url)"'

    A jq filter to apply to the return data.

POST data may also be passed as keyword arguments:

  • auto_init,
  • description
  • gitignore_template
  • has_downloads
  • has_issues
  • has_wiki,
  • homepage
  • organization
  • private
  • team_id

delete_repo

Delete a repository for a user or organization

Usage:

delete_repo owner repo

The currently authenticated user must have the delete_repo scope. Viewcurrent scopes with the show_scopes() function.

Positional arguments

  • owner="$1"

    Name of the new repo

  • repo="$2"

    Name of the new repo

fork_repo

Fork a repository from a user or organization to own account or organization

Usage:

fork_repo owner repo

Positional arguments

  • owner="$1"

    Name of existing user or organization

  • repo="$2"

    Name of the existing repo

Keyword arguments

  • _filter='"\(.clone_url)\t\(.ssh_url)"'

    A jq filter to apply to the return data.

POST data may also be passed as keyword arguments:

  • organization (The organization to clone into; default: your personal account)

list_releases

List releases for a repository

https://developer.github.com/v3/repos/releases/#list-releases-for-a-repository

Usage:

list_releases org repo '\(.assets[0].name)\t\(.name.id)'

Positional arguments

  • owner="$1"

    A GitHub user or organization.

  • repo="$2"

    A GitHub repository.

Keyword arguments

  • _filter='.[] | "\(.name)\t\(.tag_name)\t\(.id)\t\(.html_url)"'

    A jq filter to apply to the return data.

release

Get a release

https://developer.github.com/v3/repos/releases/#get-a-single-release

Usage:

release user repo 1087855

Positional arguments

  • owner="$1"

    A GitHub user or organization.

  • repo="$2"

    A GitHub repository.

  • release_id="$3"

    The unique ID of the release; see list_releases.

Keyword arguments

  • _filter='"\(.author.login)\t\(.published_at)"'

    A jq filter to apply to the return data.

create_release

Create a release

https://developer.github.com/v3/repos/releases/#create-a-release

Usage:

create_release org repo v1.2.3
create_release user repo v3.2.1 draft=true

Positional arguments

  • owner="$1"

    A GitHub user or organization.

  • repo="$2"

    A GitHub repository.

  • tag_name="$3"

    Git tag from which to create release.

Keyword arguments

  • _filter='"\(.name)\t\(.id)\t\(.html_url)"'

    A jq filter to apply to the return data.

POST data may also be passed as keyword arguments:

  • body
  • draft
  • name
  • prerelease
  • target_commitish

edit_release

Edit a release

https://developer.github.com/v3/repos/releases/#edit-a-release

Usage:

edit_release org repo 1087855 name='Foo Bar 1.4.6'
edit_release user repo 1087855 draft=false

Positional arguments

  • owner="$1"

    A GitHub user or organization.

  • repo="$2"

    A GitHub repository.

  • release_id="$3"

    The unique ID of the release; see list_releases.

Keyword arguments

  • _filter='"\(.tag_name)\t\(.name)\t\(.html_url)"'

    A jq filter to apply to the return data.

POST data may also be passed as keyword arguments:

  • tag_name
  • body
  • draft
  • name
  • prerelease
  • target_commitish

delete_release

Delete a release

https://developer.github.com/v3/repos/releases/#delete-a-release

Usage:

delete_release org repo 1087855

Return: 0 for success; 1 for failure.

Positional arguments

  • owner="$1"

    A GitHub user or organization.

  • repo="$2"

    A GitHub repository.

  • release_id="$3"

    The unique ID of the release; see list_releases.

release_assets

List release assets

https://developer.github.com/v3/repos/releases/#list-assets-for-a-release

Usage:

release_assets user repo 1087855

Example of downloading release assets:

ok.sh release_assets <user> <repo> <release_id> \
        _filter='.[] | .browser_download_url' \
    | xargs -L1 curl -L -O

Example of the multi-step process for grabbing the release ID fora specific version, then grabbing the release asset IDs, and thendownloading all the release assets (whew!):

username='myuser'
repo='myrepo'
release_tag='v1.2.3'
ok.sh list_releases "$myuser" "$myrepo" \
    | awk -F'\t' -v tag="$release_tag" '$2 == tag { print $3 }' \
    | xargs -I{} ./ok.sh release_assets "$myuser" "$myrepo" {} \
        _filter='.[] | .browser_download_url' \
    | xargs -L1 curl -n -L -O

Positional arguments

  • owner="$1"

    A GitHub user or organization.

  • repo="$2"

    A GitHub repository.

  • release_id="$3"

    The unique ID of the release; see list_releases.

Keyword arguments

  • _filter='.[] | "\(.id)\t\(.name)\t\(.updated_at)"'

    A jq filter to apply to the return data.

upload_asset

Upload a release asset

https://developer.github.com/v3/repos/releases/#upload-a-release-asset

Usage:

upload_asset https://<upload-url> /path/to/file.zip

The upload URL can be gotten from release(). There are multiple stepsrequired to upload a file: get the release ID, get the upload URL, parsethe upload URL, then finally upload the file. For example:

USER="someuser"
REPO="somerepo"
TAG="1.2.3"
FILE_NAME="foo.zip"
FILE_PATH="/path/to/foo.zip"

# Create a release then upload a file:
ok.sh create_release "$USER" "$REPO" "$TAG" _filter='.upload_url' \
    | sed 's/{.*$/?name='"$FILE_NAME"'/' \
    | xargs -I@ ok.sh upload_asset @ "$FILE_PATH"

# Find a release by tag then upload a file:
ok.sh list_releases "$USER" "$REPO" \
    | awk -v "tag=$TAG" -F'\t' '$2 == tag { print $3 }' \
    | xargs -I@ ok.sh release "$USER" "$REPO" @ _filter='.upload_url' \
    | sed 's/{.*$/?name='"$FILE_NAME"'/' \
    | xargs -I@ ok.sh upload_asset @ "$FILE_PATH"

Positional arguments

  • upload_url="$1"

The parsed upload_url returned from GitHub.

  • file_path="$2"

    A path to the file that should be uploaded.

Keyword arguments

  • _filter='"\(.state)\t\(.browser_download_url)"'

    A jq filter to apply to the return data.

Also any other keyword arguments accepted by _post().

list_milestones

List milestones for a repository

Usage:

list_milestones someuser/somerepo
list_milestones someuser/somerepo state=closed

Positional arguments

  • repository="$1"

    A GitHub repository.

Keyword arguments

  • _follow_next

    Automatically look for a 'Links' header and follow any 'next' URLs.

  • _follow_next_limit

    Maximum number of 'next' URLs to follow before stopping.

  • _filter='.[] | "\(.number)\t\(.open_issues)/\(.closed_issues)\t\(.title)"'

    A jq filter to apply to the return data.

GitHub querystring arguments may also be passed as keyword arguments:

  • direction
  • per_page
  • sort
  • state

create_milestone

Create a milestone for a repository

Usage:

create_milestone someuser/somerepo MyMilestone

create_milestone someuser/somerepo MyMilestone \
    due_on=2015-06-16T16:54:00Z \
    description='Long description here
that spans multiple lines.'

Positional arguments

  • repo="$1"

    A GitHub repository.

  • title="$2"

    A unique title.

Keyword arguments

  • _filter='"\(.number)\t\(.html_url)"'

    A jq filter to apply to the return data.

Milestone options may also be passed as keyword arguments:

  • description
  • due_on
  • state

list_issue_comments

List comments of a specified issue.( https://developer.github.com/v3/issues/comments/#list-issue-comments )

Usage:

list_issue_comments someuser/somerepo number

Positional arguments

GitHub owner login or id for which to list branchesName of the repo for which to list branchesIssue number

  • repo="$1"

  • number="$2"

add_comment

Add a comment to an issue

Usage:

add_comment someuser/somerepo 123 'This is a comment'

Positional arguments

  • repository="$1"

    A GitHub repository

  • number="$2"

    Issue Number

  • comment="$3"

    Comment to be added

Keyword arguments

  • _filter='"\(.id)\t\(.html_url)"'

    A jq filter to apply to the return data.

list_commit_comments

List comments of a specified commit.( https://developer.github.com/v3/repos/comments/#list-commit-comments )

Usage:

list_commit_comments someuser/somerepo sha

Positional arguments

GitHub owner login or id for which to list branchesName of the repo for which to list branchesCommit SHA

  • repo="$1"

  • sha="$2"

add_commit_comment

Add a comment to a commit

Usage:

add_commit_comment someuser/somerepo 123 'This is a comment'

Positional arguments

  • repository="$1"

    A GitHub repository

  • hash="$2"

    Commit hash

  • comment="$3"

    Comment to be added

Keyword arguments

  • _filter='"\(.id)\t\(.html_url)"'

    A jq filter to apply to the return data.

close_issue

Close an issue

Usage:

close_issue someuser/somerepo 123

Positional arguments

  • repository="$1"

    A GitHub repository

  • number="$2"

    Issue Number

Keyword arguments

  • _filter='"\(.id)\t\(.state)\t\(.html_url)"'

    A jq filter to apply to the return data.

POST data may also be passed as keyword arguments:

  • assignee
  • labels
  • milestone

list_issues

List issues for the authenticated user or repository

Usage:

list_issues
list_issues someuser/somerepo
list_issues <any of the above> state=closed labels=foo,bar

Positional arguments

user or user/repository

Keyword arguments

  • _follow_next

    Automatically look for a 'Links' header and follow any 'next' URLs.

  • _follow_next_limit

    Maximum number of 'next' URLs to follow before stopping.

  • _filter='.[] | "\(.number)\t\(.title)"'

    A jq filter to apply to the return data.

GitHub querystring arguments may also be passed as keyword arguments:

  • assignee
  • creator
  • direction
  • labels
  • mentioned
  • milestone
  • per_page
  • since
  • sort
  • state

user_issues

List all issues across owned and member repositories for the authenticated user

Usage:

user_issues
user_issues since=2015-60-11T00:09:00Z

Keyword arguments

  • _follow_next

    Automatically look for a 'Links' header and follow any 'next' URLs.

  • _follow_next_limit

    Maximum number of 'next' URLs to follow before stopping.

  • _filter='.[] | "\(.repository.full_name)\t\(.number)\t\(.title)"'

    A jq filter to apply to the return data.

GitHub querystring arguments may also be passed as keyword arguments:

  • direction
  • filter
  • labels
  • per_page
  • since
  • sort
  • state

create_issue

Create an issue

Usage:

create_issue owner repo 'Issue title' body='Add multiline body
content here' labels="$(./ok.sh _format_json -a foo bar)"

Positional arguments

  • owner="$1"

    A GitHub repository.

  • repo="$2"

    A GitHub repository.

  • title="$3"

    A GitHub repository.

Keyword arguments

  • _filter='"\(.id)\t\(.number)\t\(.html_url)"'

    A jq filter to apply to the return data.

Additional issue fields may be passed as keyword arguments:

  • body (string)
  • assignee (string)
  • milestone (integer)
  • labels (array of strings)
  • assignees (array of strings)

org_issues

List all issues for a given organization for the authenticated user

Usage:

org_issues someorg

Positional arguments

  • org="$1"

    Organization GitHub login or id.

Keyword arguments

  • _follow_next

    Automatically look for a 'Links' header and follow any 'next' URLs.

  • _follow_next_limit

    Maximum number of 'next' URLs to follow before stopping.

  • _filter='.[] | "\(.number)\t\(.title)"'

    A jq filter to apply to the return data.

GitHub querystring arguments may also be passed as keyword arguments:

  • direction
  • filter
  • labels
  • per_page
  • since
  • sort
  • state

list_starred

List starred repositories

Usage:

list_starred
list_starred user

Positional arguments

  • user="$1"

    Optional GitHub user login or id for which to list the starred repos.

Keyword arguments

  • _filter='.[] | "\(.name)\t\(.html_url)"'

    A jq filter to apply to the return data.

Querystring arguments may also be passed as keyword arguments:

  • direction
  • per_page
  • sort
  • type

list_my_orgs

List your organizations

Usage:

list_my_orgs

Keyword arguments

  • _follow_next

    Automatically look for a 'Links' header and follow any 'next' URLs.

  • _follow_next_limit

    Maximum number of 'next' URLs to follow before stopping.

  • _filter='.[] | "\(.login)\t\(.id)"'

    A jq filter to apply to the return data.

list_orgs

List all organizations

Usage:

list_orgs

Keyword arguments

  • _follow_next

    Automatically look for a 'Links' header and follow any 'next' URLs.

  • _follow_next_limit

    Maximum number of 'next' URLs to follow before stopping.

  • _filter='.[] | "\(.login)\t\(.id)"'

    A jq filter to apply to the return data.

list_users

List all users

Usage:

list_users

Keyword arguments

  • _follow_next

    Automatically look for a 'Links' header and follow any 'next' URLs.

  • _follow_next_limit

    Maximum number of 'next' URLs to follow before stopping.

  • _filter='.[] | "\(.login)\t\(.id)"'

    A jq filter to apply to the return data.

labels

List available labels for a repository

Usage:

labels someuser/somerepo

Positional arguments

  • repo="$1"

    A GitHub repository.

Keyword arguments

  • _follow_next

    Automatically look for a 'Links' header and follow any 'next' URLs.

  • _follow_next_limit

    Maximum number of 'next' URLs to follow before stopping.

  • _filter='.[] | "\(.name)\t\(.color)"'

    A jq filter to apply to the return data.

add_label

Add a label to a repository

Usage:

add_label someuser/somerepo LabelName color

Positional arguments

  • repo="$1"

    A GitHub repository.

  • label="$2"

    A new label.

  • color="$3"

    A color, in hex, without the leading #.

Keyword arguments

  • _filter='"\(.name)\t\(.color)"'

    A jq filter to apply to the return data.

update_label

Update a label

Usage:

update_label someuser/somerepo OldLabelName \
    label=NewLabel color=newcolor

Positional arguments

  • repo="$1"

    A GitHub repository.

  • label="$2"

    The name of the label which will be updated

Keyword arguments

  • _filter='"\(.name)\t\(.color)"'

    A jq filter to apply to the return data.

Label options may also be passed as keyword arguments, these will updatethe existing values:

  • color
  • name

add_team_repo

Add a team repository

Usage:

add_team_repo team_id organization repository_name permission

Positional arguments

  • team_id="$1"

    Team id to add repository to

  • organization="$2"

    Organization to add repository to

  • repository_name="$3"

    Repository name to add

  • permission="$4"

    Permission to grant: pull, push, admin

  • url="/teams/$team_id}/repos/${organization}/${repository_name}"

list_pulls

Lists the pull requests for a repository

Usage:

list_pulls user repo

Positional arguments

  • owner="$1"

    A GitHub owner.

  • repo="$2"

    A GitHub repository.

Keyword arguments

  • _follow_next

    Automatically look for a 'Links' header and follow any 'next' URLs.

  • _follow_next_limit

    Maximum number of 'next' URLs to follow before stopping.

  • _filter='.[] | "\(.number)\t\(.user.login)\t\(.head.repo.clone_url)\t\(.head.ref)"'

    A jq filter to apply to the return data.

create_pull_request

Create a pull request for a repository

Usage:

create_pull_request someuser/somerepo title head base

create_pull_request someuser/somerepo title head base body='Description here.'

Positional arguments

  • repo="$1"

    A GitHub repository.

  • title="$2"

    A title.

  • head="$3"

    A head.

  • base="$4"

    A base.

Keyword arguments

  • _filter='"\(.number)\t\(.html_url)"'

    A jq filter to apply to the return data.

Pull request options may also be passed as keyword arguments:

  • body
  • maintainer_can_modify

update_pull_request

Update a pull request for a repository

Usage:

update_pull_request someuser/somerepo number title='New title' body='New body'

Positional arguments

  • repo="$1"

    A GitHub repository.

  • number="$2"

    A pull request number.

Keyword arguments

  • _filter='"\(.number)\t\(.html_url)"'

    A jq filter to apply to the return data.

Pull request options may also be passed as keyword arguments:

  • base
  • body
  • maintainer_can_modify
  • state (either open or closed)
  • title

transfer_repo

Transfer a repository to a user or organization

Usage:

transfer_repo owner repo new_owner
transfer_repo owner repo new_owner team_ids='[ 12, 345 ]'

Positional arguments

  • owner="$1"

    Name of the current owner

  • repo="$2"

    Name of the current repo

  • new_owner="$3"

    Name of the new owner

Keyword arguments

  • _filter='"\(.name)"'

    A jq filter to apply to the return data.

POST data may also be passed as keyword arguments:

  • team_ids

archive_repo

Archive a repo

Usage:

archive_repo owner/repo

Positional arguments

  • repo="$1"

    A GitHub repository.

  • _filter='"\(.name)\t\(.html_url)"'

    A jq filter to apply to the return data.

  • start.sh #!/bin/bash #启动服务名称 SERVER_NAME=test #服务部署路径 DEPLOY_DIR=/opt/app/test # 服务日志输出路径 STDOUT_FILE=${DEPLOY_DIR}/logs/test.log #服务启动的jar或war WAR_FILE=${DEPLOY_DIR}/test.jar PIDS=`ps -f | grep jav

  • Linux 运行 .sh 文件的两种方法 文章作者:网友投稿 发布时间:2010-06-15 13:31:16 来源:网络 一个中等水平的Linux用户一定少不了经常执行.sh文件,当然了,你可以在图形界面下面直接双击该文件,但无疑比较浪费时间。 现在介绍第一种方法:(在ubuntu下的) 首先你要打开一个终端。 然后输入sudo su 随后输入密码。这样就取得了root用户权限。 然后找到那个文

  • 从标题就可以看出了,autogen.sh是个shell脚本,它的作用就是将前一篇Linux工具之autoconf和automake讲的自动产生Makefile的过程集成到脚本中,简化操作。 接下来看看如何操作,直接上代码: #!/bin/sh echo echo ... helloworld autogen ... echo MISSING="" env aclocal --versio

  • ​​​​​​ 在ubuntu用hadoop version遇到了一个错误: Cannot execute /home/hadoop/hadoop2.8/libexec/hadoop-config.sh. 解决方法:在/etc/profile中找到了这个HADOOP_HOME全局变量,将其删除 运行source /etc/profile 输入vim .bashrc命令,在最后一行输入unset HA

  • 一,基本命令 : 1 ,启动 :         zkServer.sh start 2 ,查看状态 :         zkServer.sh status 3 ,停止 :         zkServer.sh stop 二 ,实际需要 : 1 ,启动集群 :      在每一台机器上都执行命令 : zkServer.sh start 2 ,查看状态 :      在每一台机器上都执行命令 :

  • 原因: 1.     本地根本没有virtualenvwrapper.sh这个文件             2。   ~/.bashrc文件中virtualenvwrapper.sh文件的path配置不对。 在安装virtualenvwrapper时,并没有生成virtualenvwrapper.sh这个文件,使用命令 find / -name virtualenvwrapper.sh 无法找到这

  • 权限问题 错误显示 permission denied: (base) aaa@amax:~/project$ script/make_dirs.sh -bash: script/make_dirs.sh: Permission denied 解决方案1: bash命令运行: bash script/make_dirs.sh 解决方案2: 先修改.sh文件权限,再运行原命令: chmod +x s

  • 1.打开文件是白色的,很有可能你是通过非root用户登录的,你要执行.sh文件是没有权限的,需要给这个.sh文件加上执行权限就OK了.亲测可用.  linux给文件加可执行权限 1、加最高权限 chmod 775  文件名 2、加可执行权限 chmod +x   文件名 2. 当然还有可能一种是 你的.sh文件是windows创建的,当你拷贝到linux时,此文件是不能运行的,你需要   解决方法

  • 一、添加sheel脚本 1、首先创建一个执行程序:vim a.sh 2、编辑: #!/bin/bash python3  python.py >> test2.log 2>&1 3、添加权限:chmod +x ./a.sh 4、查看执行结果: ./a.sh 二、添加定时任务 安装:apt-get install cron   (服务器环境下默认都会安装) 1、crontab –e : 修改 cro

  • 一、使用背景       鉴于业务需求,需要编写一个脚本文件,用于不间断的获取一些信息。这里用shell脚本是最方面的,循环执行我们的请求方法即可。 二、shell脚本编写过程 (1)创建 test.sh文件 //使用touch命令创建文件 touch test.sh (2)编写test.sh 文件 vim test.sh //此时开始编写 i //进入编写模式 //下面是.sh文件内容 #!

  • sh + ./run.sh 在当前目录找到要运行的文件,我要运行的是run.sh,直接执行这个命令。ok,没有提示错误,运行成功。当然,也可以加点打印日志,表明改程序执行了。 修改权限 1.运行chmod u+x run.sh,修改文件权限; 2.直接运行./run.sh,可以正常运行 总结: 就以上2种方式,都是ok的,第一种,可以运行,只不过每次都要执行sh+run.sh,太过麻烦;建议采用

相关阅读

相关文章

相关问答

相关文档