Age | Commit message (Collapse) | Author |
|
Specify that Git branch names must be prefixed with a four-digit Redmine
issue number.
|
|
|
|
|
|
Don't output the Curl progress bar which can be jarring since you're not
expecting it.
|
|
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.
|
|
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.
|
|
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.
|
|
If this command line argument was passed, the program would go into an
infinite loop, prevented from finishing argument parsing.
|
|
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.
|
|
|
|
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.
|
|
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.
|
|
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.
|
|
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()`.
|
|
Get the username from the command line argument-loaded variable instead
of my hard-coded username.
|
|
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.
|
|
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.
|
|
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'.
|
|
|
|
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.
|
|
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.
|
|
Take the opportunity to do some line wrapping in the help output also.
|
|
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
|
|
|
|
Get rid of duplicated PR hash building and filtering code.
|
|
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.
|
|
Describe what these functions do for better documentation and
comprehension.
|
|
|
|
Must have forgotten to do this.
|
|
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.
|
|
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.
|
|
Make authenticated requests to the Redmine API so that the requests
actually go through successfully.
|
|
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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`.
|
|
Using `$HOME` as a temporary location for testing.
|
|
Forgot to use the `local` keyword. Let's write decent Bash and use local
variables.
|
|
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.
|