aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2023-12-08code-review-gh-start: Add "origin/" prefix to merge baseHEADmasterTeddy Wing
True, the remote name is not necessarily going to be called "origin", but that's a reasonable default. This allows commit ranges to work even when the merge base branch hasn't been created locally.
2023-11-24Update copyright years on recently changed filesTeddy Wing
2023-11-24code-review-changed-files: Move "..." back to `get_merge_base`Teddy Wing
It's more convenient to have the "..." here because all of the code-review commands use `get_merge_base`. Otherwise I'd end up having to add it to most of the other commands. But now, instead of only adding it to the default merge base, add it to all merge bases, including the one set by `code-review-start`. This makes all merge bases consistent, and means you don't have to include the dots when setting a custom merge base.
2023-11-24Add 'code-review-ddiff'Teddy Wing
This is inspired by a Git alias I have, `git ddiff`, that opens the Git diff in the Delta diff viewer (https://github.com/dandavison/delta). Delta ends up being much nicer than regular Git diff for code reviews because it renders syntax highlighting.
2023-11-24code-review-database: Add environment variable for merge baseTeddy Wing
I was inspired by Jake Zimmerman's blog post "Code Review from the Command Line" (https://blog.jez.io/cli-code-review/) to add an environment variable override for the merge base. This allows us to set a different merge base for individual command executions.
2023-11-24code-review-stat: Pass arguments to GitTeddy Wing
This allows us to pass along arguments like `--ignore-all-space`.
2023-11-24code-review-difftool: Focus new changes buffer instead of old versionTeddy Wing
Previously, the focused window in each tab was the Fugitive window that contained the old version of the file. It's nicer to have the new version focused by default, because that allows you to make changes to the local source code.
2023-11-24code-review-database: Remove "..." from merge baseTeddy Wing
I don't think this is the right approach, but since I added the "..." in `code-review-changed-files` in 7659cf07f118fec4c1ba9677c82a7ef61511e797, removing the "..." from here allows the difftool script to work when using the default merge base.
2023-10-30code-review-changed-files: Add "..." to the merge baseTeddy Wing
Doesn't cover all the cases, but I think this should give us the correct set of files when the merge base has been set via `code-review-start`. Otherwise we might end up with a bunch of files that came from other branches, not the one we're reviewing now.
2023-08-08Merge branch 'github-merge-base'Teddy Wing
2023-08-08code-review.bash-completion: Update copyright yearTeddy Wing
2023-08-08code-review.bash-completion: Add `gh-start` to subcommandsTeddy Wing
Realistically I should match based on the executable files available that start with "code-review-", but this is how it works currently, so it's less effort to add to what's already here.
2023-07-27code-review-gh-start: Get the merge base from the GitHub APITeddy Wing
Haven't tested this yet, but the idea is to use the `gh` CLI to call the GitHub API and get the list of pulls requests. These are filtered to get the one open for the current branch, and we can then get its merge base and start a `code-review` review using that merge base.
2023-07-27code-review-gh-start: Idea to get merge base from GitHub API via gh CLITeddy Wing
2023-07-27code-review-gh-start: Idea to get merge base from GitHub pull requestTeddy Wing
To alleviate dealing with repositories that don't use "master" as their master branch.
2023-07-26code-review-difftool: Use newer vim-fugitive diff commandTeddy Wing
The Fugitive documentation says that `Gdiff` is deprecated. In the current version, you need to use the `Gvdiffsplit` command to get a side-by-side diff with a vertical split.
2023-07-26code-review.bash-completion: Add note about completion for subcommandsTeddy Wing
2019-12-04Add 'code-review-log'Teddy Wing
Wraps `git log` to show commits since the merge base.
2019-11-08code-review-difftool: Turn off swap filesTeddy Wing
When the files being opened with `difftool` are already open in a Vim instance, a 'swap file already exists' confirmation warning is displayed for each file. Bypass the warning by not saving swap files (using the -n command line option).
2019-06-17code-review-difftool: Remove `extglob` `shopt` maneuversTeddy Wing
Turns out I don't need to worry about setting or unsetting `extglob` at all because the script gets executed in a subshell. Obviously. Didn't realise or test thoroughly at first.
2019-06-17code-review-difftool: Retain old `extglob` settingTeddy Wing
If `extglob` was set, we'd always unset it. Check to see if it's set before doing anything with it, and then restore it to its original value.
2019-06-17code-review-difftool: Remove commented code from 42215fe2bbefba19308bd8Teddy Wing
This was a note preceding implementation, and is no longer needed.
2019-06-17get_merge_base(): Change default base to `master...`Teddy Wing
Add the range filter to try to remove commits that we don't care about. Still not sure if this will work in all cases, as sometimes `..` seemed to give me the right collection of files and sometimes `...` did. code-review-difftool: Pass the merge base without range dots (`..` or `...`) to Vim Fugitive, as it doesn't accept revisions with ranges. Not sure what to do if I get a range with two revision names yet, though. Turns on Bash's `extglob` in order to use `?(...)` to include both patterns in the expansion.
2019-06-11code-review-database: Always try to create the databaseTeddy Wing
If the database doesn't exist, we get this error: Error: near line 3: no such table: merge_bases This is because `sqlite3` will always create a new database if it doesn't exist when running a command against a database. The newly-created database doesn't have the required table, and we get the error. Fix the problem by ensuring the database always exists and is initialised properly.
2019-06-10code-review-database: Remove TODOTeddy Wing
This was taken care of in 21534162124501f0410ee31cd31130aa3b92a9f3.
2019-06-10code-review: Add a version number and `--version` program flagTeddy Wing
2019-06-10code-review: Fix `--help` argumentTeddy Wing
The `shift` call came before I was checking the first argument `$1` if it was '--help'. This caused the program to print the 'nonexistent command' error message. Move the `shift` call to just before we pass on the rest of the command line arguments.
2019-06-10Add READMETeddy Wing
2019-06-10Add license (GNU GPLv3+)Teddy Wing
2019-06-10Add a man pageTeddy Wing
Not very detailed at the moment, just copies the usage output. Would be nice to make this more descriptive, and even better to have separate man pages for each subcommand.
2019-06-10code-review: Add usage outputTeddy Wing
Print a real usage message.
2019-06-10code-review-difftool: Remove completed TODOsTeddy Wing
2019-06-10code-review-difftool: Use `code-review-changed-files`Teddy Wing
Use the existing `code-review` tool instead of the full Git command.
2019-06-10Add code-review.bash-completionTeddy Wing
Basic Bash completion of `code-review` subcommands.
2019-06-10code-review-changed-files: Use `get_merge_base`; Print absolute pathsTeddy Wing
* Use the common merge base from `code-review-database`. * Print an absolute path to the file using `$GIT_ROOT` from `code-review-database`. This allows the paths to be useful even when PWD is a subdirectory in the Git repo.
2019-06-10Rename `git-changed-files` to `code-review-changed-files`Teddy Wing
Make the script a `code-review` subcommand. I had originally written it before the `code-review-` subcommand prefix system.
2019-06-10Use `get_merge_base` across scriptsTeddy Wing
Replace `$ARGS` system from before with the merge base value taken from the database. This makes the merge base consistent across `code-review` tools/subcommands.
2019-06-10code-review-database(create_merge_base): Upsert merge baseTeddy Wing
Don't duplicate rows if we call `create_merge_base` multiple times. Doing so would mean we'd get multiple merge base rows for the same head. Instead, overwrite the existing merge base for a given head using an upsert. Thanks a bunch to MarqueIV (https://stackoverflow.com/users/168179/marqueiv) on Stack Overflow for demonstrating a way to do an upsert without the UPSERT syntax. This enables us to do an upsert on SQLite < 3.24.0. Neat trick. https://stackoverflow.com/questions/15277373/sqlite-upsert-update-or-insert/38463024#38463024
2019-06-09code-review-start: Only insert merge_bases row if argument was passedTeddy Wing
Don't create a `merge_bases` entry in the database if no merge base argument was passed to the script. The `get_merge_base` function in `code-review-database` will default to `origin/master` or `master` when no row is found in the database. Rely on those defaults instead of always inserting a row.
2019-06-09Move database functions from code-review-start to code-review-databaseTeddy Wing
Put these functions in a function-only file that can be sourced by other scripts that need database access.
2019-06-09code-review-start: Add `get_merge_base` functionTeddy Wing
Function to get the merge base for the current branch. If none exists in the database, default to `origin/master` if there's an `origin` remote, or `master` if not. Thanks to Serpiton (https://codereview.stackexchange.com/users/61525/serpiton) on Stack Overflow for describing how to get a default value using the `MAX()` function: https://codereview.stackexchange.com/questions/74192/select-first-value-if-exists-otherwise-select-default-value/74252#74252 Thanks to 'tig' (https://stackoverflow.com/users/96823/tig) on Stack Overflow for the command to check if a given Git remote exists: https://stackoverflow.com/questions/12170459/check-if-git-remote-exists-before-first-push/26843249#26843249
2019-06-09code-review-difftool: Change `master..` to `master`Teddy Wing
Turns out some files were excluded using the `..` range.
2019-06-05code-review-start: Add TODO for upsertTeddy Wing
2019-06-05Add draft of 'code-review-start'Teddy Wing
This command will store the desired merge base for the current branch, defaulting to "origin/master". In so doing, subsequent `code-review` subcommands will have access to this and be able to default to a merge base branch instead of: * Having users specify one manually at the command line for each `code-review` subcommand * Having a default merge base branch that's not desired by users I figure I can hopefully get away with not sanitizing SQL input because I don't think you can use apostrophes in Git branch names. Otherwise I'll probably have to port this to another language with a SQLite library, as it doesn't seem possible to easily sanitize inputs in Bash.
2019-06-04code-review-difftool: Use 'vim-fugitive' instead of 'vdwrap'Teddy Wing
Fugitive seems to have fewer surprises and basically just work in Vim.
2019-06-04Add code-review-commitsTeddy Wing
Output a short log of commits.
2019-06-04Add code-review-statTeddy Wing
Outputs a stat of the changed files.
2019-06-03code-review: Pass arguments to subcommand programTeddy Wing
Since subcommands are separate programs, we need to make sure we pass all remaining arguments along to the subcommand. Without this, I wasn't able to pass a different base branch to my `diff` subcommand.
2019-06-03Add code-review-diffTeddy Wing
Script to show a Git diff of the current changes. Uses `master..` as the default base.
2019-06-03Add `code-review`, subcommand runnerTeddy Wing
This script takes a subcommand as the first argument and executes an executable called "code-review-${subcommand}", similar to the way Git does subcommands. Using this subcommand system, I can have different unrelated subcommands in separate files/scripts, making it easier to organise the code.