aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2020-03-13Merge branch 'make-branch-list-work-in-git-worktrees'HEADv0.1.4masterTeddy Wing
2020-03-13git-branch-list: Update copyright yearTeddy Wing
2020-03-13Increase version v0.1.3 -> v0.1.4Teddy Wing
2020-03-13git-branch-list: Allow commands to work in Git worktreesTeddy Wing
Previously, `git-branch-list` didn't work inside worktree directories. It expected the current directory to be a descendant of the main Git repository directory, which isn't the case for worktrees. Given a Git repository `test-repo`: $ git rev-parse --show-toplevel /tmp/test-repo $ git rev-parse --git-common-dir .git $ mkdir subdir && cd subdir $ git rev-parse --git-common-dir ../.git $ cd - $ git worktree add ../test-repo-worktree $ cd ../test-repo-worktree $ git rev-parse --show-toplevel /tmp/test-repo-worktree $ git rev-parse --git-common-dir /tmp/test-repo/.git The `git rev-parse --show-toplevel` command outputs the top-level path of the worktree, not the main repository directory. Using `git rev-parse --git-common-dir`, we can get the correct path whether we're in a subdirectory or a worktree.
2019-12-09CHANGELOG: Add entry for `clear` subcommand Bash completionv0.1.3Teddy Wing
2019-12-09git-branch-list.bash-completion: Update copyright yearTeddy Wing
2019-12-09git-branch-list.bash-completion: Complete `clear` subcommandTeddy Wing
2019-12-09Migrate Homebrew formula to teddywing/formulaeTeddy Wing
Use my recent Homebrew tap to install the package instead of the formula tracked in this repo. This makes the install command shorter, and enables easy upgrades of package (with `brew upgrade git-branch-list`). The new install formula (copied from the one in this repo) has moved here: https://github.com/teddywing/homebrew-formulae/blob/b21a00cf4/HomebrewFormula/git-branch-list.rb
2019-12-09git-branch-list: Update copyright yearTeddy Wing
2019-12-09Increase version v0.1.2 -> v0.1.3Teddy Wing
2019-12-09Merge branch 'fix-operations-when-there-are-more-than-ten-saved-branches'Teddy Wing
2019-12-09git-branch-list: Fix checkout and drop commands for >10 saved branchesTeddy Wing
Previously there was a bug when you had 11 or more saved branches. Saved branches 1 and 11 would both get matched by the regex in `branch_by_id`, causing the two branches to be concatenated. This resulted in a checkout error, preventing checkout. When dropping a branch, both in the pair would be dropped, even if only branch #1 was specified. Surround the branch IDs with whitespace to prevent incorrect matches.
2019-05-25Homebrew: Update for v0.1.2Teddy Wing
2019-05-25Increase version v0.1.1 -> v0.1.2v0.1.2Teddy Wing
2019-05-25Merge branch 'update-help-output'Teddy Wing
2019-05-25git-branch-list(usage): Add `clear` command; Drop is variadicTeddy Wing
* Add the `clear` command to the help * Update the `drop` command to indicate that multiple branch IDs can be passed as arguments Looks like I forgot to update the help when I made those changes.
2019-05-25Merge branch 'make-program-work-in-subdirectories'Teddy Wing
2019-05-25git-branch-list: Make the branch list work in subdirectoriesTeddy Wing
When the current directory was not the Git root, the command wouldn't work. It expected to find the branch list database in the `.git` directory in the current directory. Make the program work even if the current directory is a subdirectory of the Git repository.
2018-04-20Homebrew: Update for v0.1.1Teddy Wing
2018-04-20Increase version v0.1.0 -> v0.1.1v0.1.1Teddy Wing
2018-04-19Merge branch 'fix-drop-for-branch-names-with-slashes'Teddy Wing
2018-04-19git-branch-list(drop): Fix deletion for branches with slashesTeddy Wing
Previously, if a branch name had slashes in it, the `drop` command would fail. This is because it used `sed` with `/` separators, and the unescaped slashes in the branch name would mess up sed's pattern. Change this to use grep instead of sed so we don't have to worry about escaping and special characters in branch names.
2018-04-19Merge branch 'fix-drop-for-branches-with-similar-names'Teddy Wing
2018-04-19git-branch-list(save): Allow saving branches with similar namesTeddy Wing
It wasn't possible to save branches with similar names before: $ git branch-list save a-branch-with-suffix $ git branch-list save a-branch #=> Errors $ git branch-list 1 a-branch-with-suffix This is because I wasn't matching against the whole line, so partial matches would set off the condition and exit. Use grep's `--line-regexp` flag to match against whole lines. Thanks to John Kugelman for the flag: https://stackoverflow.com/questions/4709912/how-to-make-grep-only-match-if-the-entire-line-matches/4709925#4709925
2018-04-19git-branch-list(drop): Support multiple branches with similar namesTeddy Wing
Previously if you had multiple branches with similar names, they could all be deleted when deleting a single one. For example: $ git branch-list 1 a-branch-with-suffix 2 a-branch $ git branch-list drop 2 $ git branch-list $ Change the regex used to match branches to drop to match the whole line, so we don't accidentally delete a branch when it has a positive partial match.
2018-03-22Homebrew: Update for v0.1.0Teddy Wing
2018-03-21Increase version v0.0.1 -> v0.1.0v0.1.0Teddy Wing
2018-03-21Add CHANGELOGTeddy Wing
Describe new features since the initial release.
2018-03-21Merge branch 'drop-multiple-branches'Teddy Wing
2018-03-21Merge branch 'clear-command'Teddy Wing
2018-03-21git-branch-list(drop): Add support for multiple branch argumentsTeddy Wing
Allow users to drop multiple branches in a single command. Instead of: $ git branch-list 1 $ git branch-list 3 $ git branch-list 4 you can now do: $ git branch-list 1 3 4 This makes it easier to drop a bunch of branches that you no longer need saved. drop_branch(): * No longer uses `branch_or_current_branch()`. Kept that function around because I didn't feel like touching the `save_branch()` code, and extracted the Git command to get the current branch to a new `current_branch()` function. * Used one loop to get branch names from IDs if necessary and feed these into a Bash array. A second loop just after deletes all branches in the branch array using the `sed` method from before. Didn't feel like changing the `sed` command so did it this way. That said, we're probably going to have to come back to it sooner or later because it's not going to be able to handle branch names containing slashes. main `case`: Change `drop_branch` call to pass it all command line arguments, except the 0th argument, which is the "drop" command (this is why we `shift` before calling the function). 101-drop-accepts-multiple-branch-arguments.t: Update test expectation which had an extra newline at the start of the string which isn't there in the real `git branch-list` output.
2018-03-21Add `drop` command testsTeddy Wing
2018-03-18git-branch-list(drop): Show error message when branch not foundTeddy Wing
Instead of displaying the underlying errors: sed: first RE may not be empty rm: .git/info/git-branch-list.bak: No such file or directory display a meaningful error message from our program to let users know that the given branch couldn't be found in the branch-list database.
2018-03-18t/: Move `$BIN` variable to moduleTeddy Wing
In order to be able to easily reuse the `$BIN` variable we created in the test for the `clear` sub-command, move it to a Perl module that can be included in other tests. Add the `t/` directory to the include path when running `prove` to ensure that `bin.pm` can be found and included. Thanks to these resources for explaining Perl modules: https://perlmaven.com/how-to-create-a-perl-module-for-code-reuse https://stackoverflow.com/questions/23899121/perl-declare-and-export-variables-from-a-module/23900384#23900384 https://stackoverflow.com/questions/17931981/what-is-isa-in-perl/17932340#17932340
2018-03-18git-branch-list: Add `clear` commandTeddy Wing
A new sub-command that clears the entire branch list. This makes it easy to remove everything when all the branches in the list are stale (e.g. everything's been merged already).
2018-03-18Add TAP test structureTeddy Wing
Copied and modified from: https://github.com/teddywing/git-hook-pre-commit-python-javascript-syntax-linter/blob/efa1909/t/001-setup.t https://github.com/teddywing/git-hook-pre-commit-python-javascript-syntax-linter/blob/f6bb0d3/t/999-teardown.t
2018-02-21README: Add installation instructionsTeddy Wing
Now that we have a Homebrew formula, we can reference it here.
2018-02-21Add Homebrew formulaTeddy Wing
Make it easier to install the program using Homebrew.
2018-02-21Add READMEv0.0.1Teddy Wing
Include a description, an example shell session, and license information.
2018-02-21git-branch-list: Remove `$?` from `exit`Teddy Wing
Without an argument, `exit` will, like `return`, use the exit status of the last command executed. The `$?` is therefore redundant and can be removed.
2018-02-21git-branch-list: Add a flag to output the program versionTeddy Wing
2018-02-21Add Bash completionTeddy Wing
Used https://github.com/git/git/blob/7cc763aaa3f39c62e0b2d5520e9d2bd8e4f3c4b3/contrib/completion/git-completion.bash as a reference. Learned how to set up completion for a custom subcommand from: https://github.com/bobthecow/git-flow-completion/blob/4180a3a0e1b286d5f35fefbea5adf5ce9875ecc3/git-flow-completion.bash
2018-02-21git-branch-list(is_a_branch): Remove `$?` from `return`Teddy Wing
I had forgotten when I wrote this, but the Bash help says: > If N is omitted, the return status is that of the last command. Meaning we don't need to explicitly return the code from the last command as that's what happens by default.
2018-02-21git-branch-list: Update usage to include optional `<branch-name>`Teddy Wing
The `save` and `drop` commands both take an optional branch name to operate on.
2018-02-21Add license (GNU GPLv3+)Teddy Wing
And include a header comment containing a short description of the program.
2018-02-21git-branch-list: Add usage outputTeddy Wing
Not using `--help` because Git uses this flag to open a `man` page for the subcommand, and I don't have a `man` page.
2018-02-20git-branch-list: Remove obsolete commentsTeddy Wing
Some ideas or old versions of code that is no longer relevant. I've also decided not to implement the TODO and have the list IDs change when you change the list like in `git stash`, at least for now. I'll keep the TODO in mind when I use the program and reevaluate to see whether it makes sense to have fixed IDs.
2018-02-20git-branch-list(drop_branch): Remove `sed` backup fileTeddy Wing
We don't really care about this backup file, so once the `sed` operation is finished, remove it.
2018-02-20git-branch-list(is_a_branch): Quiet `git rev-parse`Teddy Wing
We only care about the return code here. If `git rev-parse --verify` is successful or if it fails to find a branch with the given name, it will write output. We don't want this output to be printed, so send it to `/dev/null`.
2018-02-20git-branch-list(drop_branch): Allow dropping branches by IDTeddy Wing
In addition to letting you drop the current branch and a parameter with the name of the branch, allow branches to be dropped by their ID if they don't match an existing branch. Extract the code that finds a branch in the database by its ID to a function so it can be used by both the `checkout_branch` and `drop_branch` functions.