aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2018-04-20README: Add a note about branch name Redmine IDsHEADv0.0.1masterTeddy Wing
Specify that Git branch names must be prefixed with a four-digit Redmine issue number.
2018-04-20Add READMETeddy Wing
2018-04-20Add license (GNU GPLv3+)Teddy Wing
2018-04-19update_redmine_status(): Run Curl silentlyTeddy Wing
Don't output the Curl progress bar which can be jarring since you're not expecting it.
2018-04-19update_redmine_status(): Remove `--head` argument from Curl callTeddy Wing
When I ran this code I got the following error: Warning: You can only select one HTTP request method! You asked for both POST Warning: (-d, --data) and HEAD (-I, --head). redprine: error: Redmine API error, status code Looks like in order to make my PUT request I need to get rid of the 'only headers' flag.
2018-04-19main(): Get rid of `update_cache_with_new_pulls()` callTeddy Wing
I changed that function around in 3c451d5f504c9872e4b589c998d52479f38aabbc such that now it gets called directly by `update_redmine_status`, so we need to remove it here. Also this line caused an error because the function was renamed.
2018-04-19Set `$CACHE_FILE` in `preflight()`Teddy Wing
We had initialised the `$CACHE_FILE` variable at the start of the script, but because at that point `$GITHUB_OWNER_REPO` is empty, the cache file just ends up getting called ".json". In order to get the name we want, we need to wait until the `$GITHUB_OWNER_REPO` variable is initialised by the command line argument. Initialise `$CACHE_FILE` in `preflight()` because it makes sense to put it in that kind of setup function. Move `preflight()` after `parse_arguments()` to ensure the program variables (including `$GITHUB_OWNER_REPO`) are properly validated and initialised before running setup code.
2018-04-19Fix infinite loop when `--cache-only` argument givenTeddy Wing
If this command line argument was passed, the program would go into an infinite loop, prevented from finishing argument parsing.
2018-04-19extract_data_from_pull_request_json(): Quote usernameTeddy Wing
When I switched this over to use the variable, I forgot to retain the double quotes around the username string required by `jq`. Add these in so that the username can be parsed as a properly quoted string.
2018-04-19Add versionTeddy Wing
2018-04-19Add a command line argument to store cache without updating issuesTeddy Wing
This is to enable open pull requests to be added to the "do not update" list in cases where you have open pull requests but have just started using Redprine and have already updated the Redmine issues of the open PRs manually.
2018-04-19Make the Redmine issue fields to update customisableTeddy Wing
Add a new command line argument that accepts a Bash script string that will output the JSON wanted when making the request to update the Redmine issue. This allows the JSON to be customised to any fields the user wants to update instead of the ones I hard-coded. The param is a Bash-executable string to allow us to pass the pull request URL in to it for use in the JSON.
2018-04-19update_redmine_status(): Update the cache file after Redmine requestTeddy Wing
After making the request to update the Redmine issue and after checking for an error response, update the cache file to prepend the newly-updated pull request, marking it as one we should exclude in the future.
2018-04-19update_redmine_statuses(): Take pull request JSON instead of TSVTeddy Wing
This function now takes an array of pull requests as JSON instead of as TSV. Doing so allows us to pass a single pull request JSON string to `update_redmine_status()` and have it deal with extracting the issue number and pull request URL. Doing this because I want to be able to incrementally update the cache file on successful Redmine update. The functions that extracted the issue ID and pull request URL have been renamed to singular versions of themselves now that they only treat a single pull request hash instead of an array of them. A new function takes an array of pull request hashes and uses `jq` to output each one on a separate line, enabling us to easily loop through each one in `update_redmine_statuses()`.
2018-04-19extract_data_from_pull_request_json(): Use real GitHub usernameTeddy Wing
Get the username from the command line argument-loaded variable instead of my hard-coded username.
2018-04-19update_redmine_status(): Print error if Redmine request failsTeddy Wing
We want the program to error if the update fails, because that's kind of the whole point. Thanks to 'pvandenberk' for the explanation of how to get the HTTP status code from Curl: https://superuser.com/questions/272265/getting-curl-to-output-http-status-code/442395#442395 $ curl -s -o /dev/null -w "%{http_code}" http://www.example.org/ $ curl -s -o /dev/null -I -w "%{http_code}" http://www.example.org/ The error information isn't really enough (we only print the status code, not a real error message from Redmine), but I'm letting it slide for laziness. Now that we're exiting from the program on a Redmine error, it means the cache won't get updated with successful Redmine updated PRs. We need a way to only store successfully updated issue PRs to the cache file at the end of the run.
2018-04-19preflight(): Initialise cache fileTeddy Wing
If no cache file is present, `new_pull_requests()` should fail. To allow it to continue to function even in the absence of a cache file, initialise the cache file with an empty JSON array.
2018-04-18Store cache file in `XDG_DATA_HOME`; Rename cache fileTeddy Wing
Get rid of the temporary location and name of our cache file. Now use the XDG data directory and create ourselves a subdirectory under it where we can store our cache files. We want a separate cache file for each repository you run Redprine against. To differentiate the cache files, name them with the owner-repo combination passed in as a command line argument. Get rid of the slash in the owner-repo string because this is a filename. For example, 'eagle-jump/engine' turns into 'eagle-jump--engine'.
2018-04-18Move our main function calls into a `main()` functionTeddy Wing
2018-04-18argument_error(): Exit after printingTeddy Wing
I previously changed this to only print instead of print and exit because that allowed me to show all errors for multiple missing required arguments. The trouble was, the script would just keep running afterward even with missing arguments. To make things simpler, don't bother tracking all our requirements and just fail fast after the first error so we don't end up executing the program without all required data.
2018-04-18Replace `github_owner_repo()` function with value from argumentTeddy Wing
Get this value from a command line argument instead of getting it from the repository. Doing this because I want this script to be able to be executed outside the context of a Git repository, meaning that we won't necessarily have access to these values intrinsically.
2018-04-18Add a command line argument for GitHub owner and repoTeddy Wing
Take the opportunity to do some line wrapping in the help output also.
2018-04-18Parse argumentsTeddy Wing
Get our API tokens etc. from command line arguments. Add a function to parse arguments, along with a few helper functions error handling. Much of this is based on my Harvester code: https://github.com/teddywing/harvester/blob/ae9528d34a2b9df1b8c6ff47f5985e4a747833f8/harvester
2018-04-18Add a usage functionTeddy Wing
2018-04-18cache_my_pull_requests(): Reuse `extract_data_from_pull_request_json`Teddy Wing
Get rid of duplicated PR hash building and filtering code.
2018-04-18Remove `extract_redmine_issue_numbers_from_pull_request()`Teddy Wing
This function is no longer used and has been superseded by `issue_numbers_and_pull_request_urls()` so that pull request URLs can be sent to Redmine.
2018-04-18Add header comments to functionsTeddy Wing
Describe what these functions do for better documentation and comprehension.
2018-04-18cache_my_pull_requests(): Quote variableTeddy Wing
2018-04-18fetch_pull_requests(): Quote variableTeddy Wing
Must have forgotten to do this.
2018-04-18Get rid of commented reference codeTeddy Wing
These are stored references to things I tried in the shell to end up with the results that we have in our uncommented functions. These are historical and no longer relevant.
2018-04-18Get rid of the `$NEW_PRS` variableTeddy Wing
Looking over the code again it dawned on me that this variable is unnecessary and overcomplicates the code. Just pass in the result from before as an argument to the function.
2018-04-18Add Redmine tokenTeddy Wing
Make authenticated requests to the Redmine API so that the requests actually go through successfully.
2018-04-18Make a note to handle errors from the Redmine update requestTeddy Wing
2018-04-18Cache updated pull requests after updating RedmineTeddy Wing
Save the pull requests that we treated and updated Redmine issues for to our cache file to ensure we don't make duplicate Redmine update requests for those PRs the next time the script is run.
2018-04-18update_redmine_status(): Build the JSON to send to RedmineTeddy Wing
This is the information that I need to update in the script. It's hard-coded for now, but I'll want to generalise it later. Maybe by making the entire JSON string a user-supplied parameter. This will update the appropriate fields for the issue.
2018-04-18update_redmine_statuses(): Don't update if there are no issuesTeddy Wing
Previously this would run `update_redmine_status()` even if `$issue_ids_and_urls` was empty, which would make an unnecessary request without the required data.
2018-04-18new_pull_requests(): Use custom JSON structureTeddy Wing
This function was broken because we were trying to subtract untreated GitHub JSON from our custom saved JSON hashes. To fix it, run the newly-fetched GitHub JSON through a version of our data extractor that for now is just copy-pasted from above.
2018-04-18Get both issue ID and pull request URL in `update_redmine_status`Teddy Wing
We were only getting the Redmine issue ID, which is necessary to make the request to update the issue. However, we also want the pull request URL so this can be included in a field in the issue. Do this by extracting the pull request URL from the PR JSON and generating a tab-separated list of issue IDs and PR URLs. We then split those two values and use them in `update_redmine_status`.
2018-04-18Save pull request JSON to a cache fileTeddy Wing
Using `$HOME` as a temporary location for testing.
2018-04-18Make all function variables `local`sTeddy Wing
Forgot to use the `local` keyword. Let's write decent Bash and use local variables.
2018-04-18Initial commit. Ideas.Teddy Wing
Tornado of a first start in the direction of what I want. Started simple from some code copied from a dotfiles bin script and built up logical next steps from there.