github_commit_status package
Modules
github_commit_status.cli module
Update Status of a commit in GitHub
This tool will update the GitHub status for a given commit SHA1. The following information needs to be given so that the update can happen:
-
GitHub Token. Personal Access Token (from Developer Settings) to give command access to update GitHub repo. See documentation for help creating. Environment variable GITHUB_COMMIT_STATUS_TOKEN is taken as the default if set.
-
The name of the GitHub repository. Environment variable GITHUB_COMMIT_STATUS_REPO is taken as the default if set.
-
The 40 character SHA commit string where the status will be updated. Environment variable GITHUB_COMMIT_STATUS_COMMIT is taken as the default if set.
-
The status of the test to be reported. There are four possible choices (error, failure, pending or success).
-
A short description
There are two modes for this command: prompt and update
Prompt
This command line was originally written as a learning exercise for a beginner course. This allows prompting for options if not provided to make this command easier to use. To enable this mode, use the subcommand "prompt".
Example::
$ github_commit_status prompt
Update
This command can be very useful as component of a shell script. To enable this functionality without the prompting, use the subcommand "update".
Example::
$ github_commit_status update --repo=my_target_repo --commit="2dd5f9ce1108d69e863444ee6486e64e0299868f" --status=pending --description="Tests are running."
cli()
Update the status of a commit in GitHub
Source code in github_commit_status/cli.py
104 105 106 107 108 109 | |
print_version(ctx, param, value)
Find version from file VERSION and print
Source code in github_commit_status/cli.py
93 94 95 96 97 98 99 100 101 | |
prompt(repo, github_token, commit, status, description)
Prompt for missing options and update GitHub
Example
$ github_commit_status prompt GitHub Token [26fee6a5d440111a2648312d458b6b4e44c20c1d]: Name of the GitHub repository []: my_target_repo Commit SHA []: 2dd5f9ce1108d69e863444ee6486e64e0299868f Status: pending Description: Tests have started
GitHub has been updated.
Source code in github_commit_status/cli.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
update(repo, commit, status, description)
If all options are provided, update GitHub
For security reasons, this subcommand does not provide an option for
--github-token as this is preserved in most shell histories.
Instead, the environment variable GITHUB_COMMIT_STATUS_TOKEN
should already be set. For example, in a bash shell::
export GITHUB_COMMIT_STATUS_TOKEN=26fee6a5d440111a2648312d458b6...
Token must be provided as part of the environment, it cannot be given as part of a command line option for security reasons.
Example
$ github_commit_status update --repo=my_target_repo \ --commit="2dd5f9ce1108d69e863444ee6486e64e0299868f" \ --status=pending --description="Tests are running."
Source code in github_commit_status/cli.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |
update_github(repo_name, github_token, commit, status, description)
Update GitHub with values given
Source code in github_commit_status/cli.py
62 63 64 65 66 67 68 69 70 71 72 73 74 | |
validate_commit_sha1(ctx, param, value)
Validate value is a valid SHA1
Source code in github_commit_status/cli.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |