mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
feat: add reverse option to git-brv (#1123)
* feat: add reverse option to git-brv When there are a large amount of branches it is often useful to see the most recent branches last as they end up closer to the prompt. This adds a new --reverse / -r option and an environment variable to set the default behavior (GIT_BRV_REVERSE). * git-brv: change to git option instead of environment variable and fix typo * wrap git option in backticks for git-brv and fix git-feature title * update git-feature docs * fix missing breaks in git-feature.md
This commit is contained in:
parent
cdbcef3227
commit
9049967232
|
|
@ -359,6 +359,13 @@ $ git brv
|
|||
2020-01-08 master origin/master 265b03e Merge pull request #816 from spacewander/git-sed-pathspec
|
||||
```
|
||||
|
||||
When your repo has many branches, it can be more convenient to see this list in reverse. This can be set as the default by setting the git-extras.brv.reverse git option to true.
|
||||
|
||||
```bash
|
||||
$ git brv --reverse
|
||||
2020-01-08 master origin/master 265b03e Merge pull request #816 from spacewander/git-sed-pathspec
|
||||
2020-01-14 adds-git-brv fork/adds-git-brv 1ca0d76 Fixes #700: Adds git-brv
|
||||
```
|
||||
|
||||
## git repl
|
||||
|
||||
|
|
|
|||
21
bin/git-brv
21
bin/git-brv
|
|
@ -7,6 +7,20 @@ if ! (( BASH_VERSINFO[0] > 4 ||
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# allow the user to set a default reverse option in an environment variable
|
||||
reverse=$(git config --get git-extras.brv.reverse || echo false)
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
-r | --reverse)
|
||||
reverse=true
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -t 1 ]]; then
|
||||
shopt -s checkwinsize
|
||||
COLUMNS=$(tput cols)
|
||||
|
|
@ -36,9 +50,14 @@ for b in "${!upstream[@]}"; do
|
|||
done
|
||||
|
||||
mapfile -t ordered < <(
|
||||
# the reverse option of git-brv causes the sort to be sorted normally rather than in reverse
|
||||
reverse_opt=""
|
||||
if [[ $reverse = false ]]; then
|
||||
reverse_opt="-r"
|
||||
fi
|
||||
for b in "${!date[@]}"; do
|
||||
printf '%d\t%s\n' "${date[$b]}" "$b"
|
||||
done | sort -rn | cut -f2-
|
||||
done | sort -n $reverse_opt | cut -f2-
|
||||
)
|
||||
|
||||
current=$(git symbolic-ref -q --short HEAD)
|
||||
|
|
|
|||
|
|
@ -26,6 +26,10 @@ _git_authors(){
|
|||
__gitcomp "-l --list --no-email"
|
||||
}
|
||||
|
||||
_git_brv(){
|
||||
__gitcomp "-r --reverse"
|
||||
}
|
||||
|
||||
_git_coauthor(){
|
||||
local oldIfs=$IFS
|
||||
IFS=$'\n'
|
||||
|
|
|
|||
|
|
@ -117,6 +117,11 @@ _git-authors() {
|
|||
'--no-email[without email]' \
|
||||
}
|
||||
|
||||
_git-brv() {
|
||||
_arguments \
|
||||
'(-r --reverse)'{-r,--reverse}'[reverse order]'
|
||||
}
|
||||
|
||||
_git-changelog() {
|
||||
_arguments \
|
||||
'(-l --list)'{-l,--list}'[list commits]' \
|
||||
|
|
|
|||
|
|
@ -82,6 +82,8 @@ complete -c git -n __fish_git_needs_command -a "$__fish_git_extras_commands"
|
|||
# authors
|
||||
complete -c git -f -n '__fish_git_using_command authors' -s l -l list -d 'show authors'
|
||||
complete -c git -f -n '__fish_git_using_command authors' -l no-email -d 'without email'
|
||||
# brv
|
||||
complete -c git -f -n '__fish_git_using_command brv' -s r -l reverse -d 'reverse the sort order'
|
||||
# bulk
|
||||
complete -c git -n '__fish_git_using_command bulk' -s a -d 'Run a git command on all workspaces and their repositories'
|
||||
complete -c git -n '__fish_git_using_command bulk' -s g -d 'Ask the user for confirmation on every execution'
|
||||
|
|
|
|||
|
|
@ -1,17 +1,23 @@
|
|||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "GIT\-BRV" "1" "January 2020" "" "Git Extras"
|
||||
.TH "GIT\-BRV" "1" "December 2023" "" "Git Extras"
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBgit\-brv\fR \- List branches sorted by their last commit date
|
||||
.
|
||||
.SH "SYNOPSIS"
|
||||
\fBgit\-brv\fR
|
||||
\fBgit\-brv\fR [\-r|\-\-reverse]
|
||||
.
|
||||
.SH "DESCRIPTION"
|
||||
Pretty listing of branches sorted by the date of their last commit\.
|
||||
.
|
||||
.SH "OPTIONS"
|
||||
\-r | \-\-reverse
|
||||
.
|
||||
.P
|
||||
Reverses the output to put the most recent branch at the bottom of the list\. This is useful when there are large amount of branches as the most recent branch is shown just above the next prompt\. This can be configured as the default by setting \fBgit\-extras\.brv\.reverse\fR to true in your git options\.
|
||||
.
|
||||
.SH "EXAMPLES"
|
||||
Simply run \fBgit brv\fR
|
||||
.
|
||||
|
|
@ -27,6 +33,21 @@ $ git brv
|
|||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.P
|
||||
To display the rows in reverse order: \fBgit brv \-\-reverse\fR
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
$ git brv \-\-reverse
|
||||
2020\-01\-08 master origin/master 265b03e Merge pull request #816 from spacewander/git\-sed\-pathspec
|
||||
2020\-01\-14 adds\-git\-brv fork/adds\-git\-brv 1ca0d76 Fixes #700: Adds git\-brv
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SH "AUTHOR"
|
||||
Written by Øsse <\fIhttps://github\.com/Osse\fR>
|
||||
.
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@
|
|||
<a href="#NAME">NAME</a>
|
||||
<a href="#SYNOPSIS">SYNOPSIS</a>
|
||||
<a href="#DESCRIPTION">DESCRIPTION</a>
|
||||
<a href="#OPTIONS">OPTIONS</a>
|
||||
<a href="#EXAMPLES">EXAMPLES</a>
|
||||
<a href="#AUTHOR">AUTHOR</a>
|
||||
<a href="#REPORTING-BUGS">REPORTING BUGS</a>
|
||||
|
|
@ -75,12 +76,18 @@
|
|||
|
||||
<h2 id="SYNOPSIS">SYNOPSIS</h2>
|
||||
|
||||
<p><code>git-brv</code></p>
|
||||
<p><code>git-brv</code> [-r|--reverse]</p>
|
||||
|
||||
<h2 id="DESCRIPTION">DESCRIPTION</h2>
|
||||
|
||||
<p> Pretty listing of branches sorted by the date of their last commit.</p>
|
||||
|
||||
<h2 id="OPTIONS">OPTIONS</h2>
|
||||
|
||||
<p> -r | --reverse</p>
|
||||
|
||||
<p> Reverses the output to put the most recent branch at the bottom of the list. This is useful when there are large amount of branches as the most recent branch is shown just above the next prompt. This can be configured as the default by setting <code>git-extras.brv.reverse</code> to true in your git options.</p>
|
||||
|
||||
<h2 id="EXAMPLES">EXAMPLES</h2>
|
||||
|
||||
<p> Simply run <code>git brv</code></p>
|
||||
|
|
@ -90,6 +97,13 @@
|
|||
2020-01-08 master origin/master 265b03e Merge pull request #816 from spacewander/git-sed-pathspec
|
||||
</code></pre>
|
||||
|
||||
<p> To display the rows in reverse order: <code>git brv --reverse</code></p>
|
||||
|
||||
<pre><code>$ git brv --reverse
|
||||
2020-01-08 master origin/master 265b03e Merge pull request #816 from spacewander/git-sed-pathspec
|
||||
2020-01-14 adds-git-brv fork/adds-git-brv 1ca0d76 Fixes #700: Adds git-brv
|
||||
</code></pre>
|
||||
|
||||
<h2 id="AUTHOR">AUTHOR</h2>
|
||||
|
||||
<p>Written by Øsse <<a href="https://github.com/Osse" data-bare-link="true">https://github.com/Osse</a>></p>
|
||||
|
|
@ -105,7 +119,7 @@
|
|||
|
||||
<ol class='man-decor man-foot man foot'>
|
||||
<li class='tl'></li>
|
||||
<li class='tc'>January 2020</li>
|
||||
<li class='tc'>December 2023</li>
|
||||
<li class='tr'>git-brv(1)</li>
|
||||
</ol>
|
||||
|
||||
|
|
|
|||
|
|
@ -3,12 +3,18 @@ git-brv(1) -- List branches sorted by their last commit date
|
|||
|
||||
## SYNOPSIS
|
||||
|
||||
`git-brv`
|
||||
`git-brv` [-r|--reverse]
|
||||
|
||||
## DESCRIPTION
|
||||
|
||||
Pretty listing of branches sorted by the date of their last commit.
|
||||
|
||||
## OPTIONS
|
||||
|
||||
-r | --reverse
|
||||
|
||||
Reverses the output to put the most recent branch at the bottom of the list. This is useful when there are large amount of branches as the most recent branch is shown just above the next prompt. This can be configured as the default by setting `git-extras.brv.reverse` to true in your git options.
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
Simply run `git brv`
|
||||
|
|
@ -17,6 +23,11 @@ git-brv(1) -- List branches sorted by their last commit date
|
|||
2020-01-14 adds-git-brv fork/adds-git-brv 1ca0d76 Fixes #700: Adds git-brv
|
||||
2020-01-08 master origin/master 265b03e Merge pull request #816 from spacewander/git-sed-pathspec
|
||||
|
||||
To display the rows in reverse order: `git brv --reverse`
|
||||
|
||||
$ git brv --reverse
|
||||
2020-01-08 master origin/master 265b03e Merge pull request #816 from spacewander/git-sed-pathspec
|
||||
2020-01-14 adds-git-brv fork/adds-git-brv 1ca0d76 Fixes #700: Adds git-brv
|
||||
|
||||
## AUTHOR
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "GIT\-FEATURE" "1" "September 2023" "" "Git Extras"
|
||||
.TH "GIT\-FEATURE" "1" "December 2023" "" "Git Extras"
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBgit\-feature\fR \- Create/Merge feature branch
|
||||
|
|
@ -173,7 +173,7 @@ $ (features\.dependency\-tracking) git checkout master
|
|||
$ git feature finish dependency tracking
|
||||
.
|
||||
.TP
|
||||
Use a \fBgit\-feature\fR option flag as part of a branch name:
|
||||
Use a \fBgit\-feature\fR option or the \fBfinish\fR command as part of a branch name:
|
||||
.
|
||||
.IP
|
||||
$ git feature \-\- finish remote
|
||||
|
|
@ -184,6 +184,12 @@ $ git feature \-\- finish remote
|
|||
.br
|
||||
$ (feature/finish\-remote) git commit \-m "Some changes"
|
||||
.
|
||||
.br
|
||||
$ (feature/finish\-remote) git checkout main
|
||||
.
|
||||
.br
|
||||
$ git feature finish \-\- finish remote
|
||||
.
|
||||
.SH "AUTHOR"
|
||||
Written by Jesús Espino <\fIjespinog@gmail\.com\fR>
|
||||
.
|
||||
|
|
|
|||
|
|
@ -77,56 +77,58 @@
|
|||
|
||||
<h2 id="SYNOPSIS">SYNOPSIS</h2>
|
||||
|
||||
<p><code>git-feature</code> [-a|--alias branch_prefix] [-s|--separator branch_separator] [-r|--remote [remote_name]] <name><br />
|
||||
<code>git-feature</code> [-a|--alias branch_prefix] [-s|--separator branch_separator] finish [--squash] <name></p>
|
||||
<p><code>git-feature</code> [-a|--alias <var>PREFIX</var>] [-s|--separator <var>SEPARATOR</var>] [-r|--remote [REMOTE_NAME]] [--from START_POINT] <var>NAME</var>...</p>
|
||||
|
||||
<p><code>git-feature</code> [-a|--alias <var>PREFIX</var>] [-s|--separator <var>SEPARATOR</var>] finish [--squash] <var>NAME</var>...</p>
|
||||
|
||||
<h2 id="DESCRIPTION">DESCRIPTION</h2>
|
||||
|
||||
<p>Create/Merge the given feature branch.</p>
|
||||
<p>Create or merge the given feature branch. The feature branch name is made from the <var>PREFIX</var>, the <var>SEPARATOR</var>, and the <var>NAME</var> joined together.</p>
|
||||
|
||||
<p>The branch <code>name</code> may be specified as multiple words which will be joined with <code>-</code> characters. If any word should start with a <code>-</code>, the name should be preceded by <code>--</code>, which will signal that option parsing should be ignored.</p>
|
||||
<p>The default <var>PREFIX</var> is <code>feature</code> and <var>SEPARATOR</var> is <code>/</code>, which can be changed (see OPTIONS and GIT CONFIG for details).</p>
|
||||
|
||||
<p>The branch <var>NAME</var> may be specified as multiple words which will be joined with <code>-</code>. If the branch name contains the word <code>finish</code> or is another OPTION, <code>--</code> should be passed to stop OPTION parsing. See the EXAMPLES for details.</p>
|
||||
|
||||
<h2 id="OPTIONS">OPTIONS</h2>
|
||||
|
||||
<p><-a|--alias branch_prefix></p>
|
||||
<dl>
|
||||
<dt><code>-a</code> <var>PREFIX</var>, <code>--alias</code> <var>PREFIX</var>:</dt><dd><p></p>
|
||||
|
||||
<p>The branch prefix to use, or <code>feature</code> if not supplied.</p>
|
||||
<p>The branch prefix to use, or <code>feature</code> if not supplied.</p></dd>
|
||||
<dt><code>-s</code> <var>SEPARATOR</var>, <code>--separator</code> <var>SEPARATOR</var>:</dt><dd><p></p>
|
||||
|
||||
<p><-s|--separator branch_separator></p>
|
||||
<p>The separator to use for joining the branch prefix and the branch name, or <code>/</code> if not supplied.</p></dd>
|
||||
<dt><code>-r</code> [REMOTE_NAME], <code>--remote</code> [REMOTE_NAME]:</dt><dd><p></p>
|
||||
|
||||
<p>The separator to use for joining the branch prefix and the branch name, or <code>/</code> if not supplied.</p>
|
||||
<p>Setup a remote tracking branch using <code>remote_name</code>. If <code>remote_name</code> is not supplied, use <code>origin</code> by default.</p></dd>
|
||||
<dt><code>--from</code> START_POINT:</dt><dd><p></p>
|
||||
|
||||
<p><-r|--remote [remote_name]></p>
|
||||
<p>Setup a start point when the branch created. If <code>--from</code> is not supplied, use the current branch by default. This option will be ignored when <code>finish</code>ing a branch.</p></dd>
|
||||
<dt class="flush"><code>finish</code>:</dt><dd><p></p>
|
||||
|
||||
<p>Setup a remote tracking branch using <code>remote_name</code>. If <code>remote_name</code> is not supplied, use <code>origin</code> by default.</p>
|
||||
<p>Merge and delete the feature branch.</p></dd>
|
||||
<dt><code>--squash</code>:</dt><dd><p></p>
|
||||
|
||||
<p><--from [start_point]></p>
|
||||
<p>Run a squash merge when <code>finish</code>ing the feature branch.</p></dd>
|
||||
<dt class="flush"><var>NAME</var>:</dt><dd><p></p>
|
||||
|
||||
<p>Setup a start point when the branch created. If <code>--from</code> is not supplied, use the current branch by default.</p>
|
||||
<p>The name of the feature branch.</p></dd>
|
||||
</dl>
|
||||
|
||||
<p><finish></p>
|
||||
|
||||
<p>Merge and delete the feature branch.</p>
|
||||
|
||||
<p><--squash></p>
|
||||
|
||||
<p>Run a squash merge.</p>
|
||||
|
||||
<p><name></p>
|
||||
|
||||
<p>The name of the feature branch.</p>
|
||||
|
||||
<h2 id="GIT-CONFIG">GIT CONFIG</h2>
|
||||
|
||||
<p>You can configure the default branch prefix and separator via git config options.</p>
|
||||
|
||||
<p> $ git config --global add git-extras.feature.prefix "branch_prefix"</p>
|
||||
<dl>
|
||||
<dt><code>git-extras.feature.prefix</code>:</dt><dd><p></p>
|
||||
|
||||
<p>The default <code>branch_prefix</code> is <code>feature</code>.</p>
|
||||
<p> $ git config --global add git-extras.feature.prefix "prefix"</p></dd>
|
||||
<dt><code>git-extras.feature.separator</code>:</dt><dd><p></p>
|
||||
|
||||
<p> $ git config --global add git-extras.feature.separator "-"</p>
|
||||
<p> $ git config --global add git-extras.feature.separator "-"</p></dd>
|
||||
</dl>
|
||||
|
||||
<p>The default <code>branch_separator</code> is <code>/</code>.</p>
|
||||
|
||||
<h2 id="EXAMPLES">EXAMPLES</h2>
|
||||
|
||||
|
|
@ -168,20 +170,22 @@ $ git feature dependency tracking<br />
|
|||
$ (features.dependency-tracking) ...<br />
|
||||
$ (features.dependency-tracking) git checkout master<br />
|
||||
$ git feature finish dependency tracking</p></dd>
|
||||
<dt>Use a <code>git-feature</code> option flag as part of a branch name:</dt><dd><p></p>
|
||||
<dt>Use a <code>git-feature</code> option or the <code>finish</code> command as part of a branch name:</dt><dd><p></p>
|
||||
|
||||
<p>$ git feature -- --remote<br />
|
||||
<p>$ git feature -- finish remote<br />
|
||||
...<br />
|
||||
$ (feature/--remote) git commit -m "Some changes"</p></dd>
|
||||
$ (feature/finish-remote) git commit -m "Some changes"<br />
|
||||
$ (feature/finish-remote) git checkout main<br />
|
||||
$ git feature finish -- finish remote</p></dd>
|
||||
</dl>
|
||||
|
||||
|
||||
<h2 id="AUTHOR">AUTHOR</h2>
|
||||
|
||||
<p>Written by Jesús Espino <<a href="mailto:jespinog@gmail.com" data-bare-link="true">jespinog@gmail.com</a>><br />
|
||||
Modified by Mark Pitman <<a href="mailto:mark.pitman@gmail.com" data-bare-link="true">mark.pitman@gmail.com</a>><br />
|
||||
Modified by Carlos Prado <<a href="mailto:carlos.prado@cpradog.com" data-bare-link="true">carlos.prado@cpradog.com</a>><br />
|
||||
Modified by Austin Ziegler <<a href="mailto:halostatue@gmail.com" data-bare-link="true">halostatue@gmail.com</a>></p>
|
||||
<p>Written by Jesús Espino <<a href="mailto:jespinog@gmail.com" data-bare-link="true">jespinog@gmail.com</a>><br />
|
||||
Modified by Mark Pitman <<a href="mailto:mark.pitman@gmail.com" data-bare-link="true">mark.pitman@gmail.com</a>><br />
|
||||
Modified by Carlos Prado <<a href="mailto:carlos.prado@cpradog.com" data-bare-link="true">carlos.prado@cpradog.com</a>><br />
|
||||
Modified by Austin Ziegler <<a href="mailto:halostatue@gmail.com" data-bare-link="true">halostatue@gmail.com</a>></p>
|
||||
|
||||
<h2 id="REPORTING-BUGS">REPORTING BUGS</h2>
|
||||
|
||||
|
|
@ -189,12 +193,12 @@ Modified by Austin Ziegler <<a href="mailto:
|
|||
|
||||
<h2 id="SEE-ALSO">SEE ALSO</h2>
|
||||
|
||||
<p><<a href="https://github.com/tj/git-extras" data-bare-link="true">https://github.com/tj/git-extras</a>></p>
|
||||
<p><<a href="https://github.com/tj/git-extras" data-bare-link="true">https://github.com/tj/git-extras</a>>, <a class="man-ref" href="git-create-branch.html">git-create-branch<span class="s">(1)</span></a>, <a class="man-ref" href="git-delete-branch.html">git-delete-branch<span class="s">(1)</span></a></p>
|
||||
|
||||
|
||||
<ol class='man-decor man-foot man foot'>
|
||||
<li class='tl'></li>
|
||||
<li class='tc'>September 2023</li>
|
||||
<li class='tc'>December 2023</li>
|
||||
<li class='tr'>git-feature(1)</li>
|
||||
</ol>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
# git-feature(1) -- Create/Merge feature branch
|
||||
git-feature(1) -- Create/Merge feature branch
|
||||
========================================================
|
||||
|
||||
## SYNOPSIS
|
||||
|
||||
|
|
@ -106,8 +107,8 @@ You can configure the default branch prefix and separator via git config options
|
|||
|
||||
$ git feature -- finish remote
|
||||
...
|
||||
$ (feature/finish-remote) git commit -m "Some changes"
|
||||
$ (feature/finish-remote) git checkout main
|
||||
$ (feature/finish-remote) git commit -m "Some changes"
|
||||
$ (feature/finish-remote) git checkout main
|
||||
$ git feature finish -- finish remote
|
||||
|
||||
## AUTHOR
|
||||
|
|
|
|||
Loading…
Reference in a new issue