Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 170702d
Showing
6 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2019 nju33 <nju33.ki@gmail.com> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<img src="https://cdn.rawgit.com/oh-my-fish/oh-my-fish/e4f1c2e0219a17e2c748b824004c8d0b38055c16/docs/logo.svg" align="left" width="144px" height="144px"/> | ||
|
||
#### age | ||
|
||
> To get next version from git tag (e.g. v1.0.0) | ||
[![MIT License](https://img.shields.io/badge/license-MIT-007EC7.svg?style=flat-square)](/LICENSE) | ||
[![Fish Shell Version](https://img.shields.io/badge/fish-v3.0.0-007EC7.svg?style=flat-square)](https://fishshell.com) | ||
[![Oh My Fish Framework](https://img.shields.io/badge/Oh%20My%20Fish-Framework-007EC7.svg?style=flat-square)](https://www.github.com/oh-my-fish/oh-my-fish) | ||
|
||
<br/> | ||
|
||
## Install | ||
|
||
```fish | ||
$ omf install age | ||
``` | ||
|
||
## Usage | ||
|
||
```sh | ||
$ git tag | ||
v0.0.1 | ||
|
||
$ age --major | ||
v1.0.0 | ||
|
||
$ age --minor | ||
v0.1.0 | ||
|
||
$ age --patch | ||
v0.0.2 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Always provide completions for command line utilities. | ||
# | ||
# Check Fish documentation about completions: | ||
# http://fishshell.com/docs/current/commands.html#complete | ||
# | ||
# If your package doesn't provide any command line utility, | ||
# feel free to remove completions directory from the project. | ||
|
||
complete -c age -l major -d 'print next major version' | ||
complete -c age -l minor -d 'print next minor version' | ||
complete -c age -l patch -d 'print next patch version' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
function age -d "Just to get next version tag on git" | ||
argparse -n age 'M/major' 'm/minor' 'p/patch' -- $argv | ||
or return 1 | ||
|
||
set -l tags (git tag --sort=-taggerdate | xargs -n 1000) | ||
|
||
set -l latest_version "v0.0.0" | ||
for tag in (string split ' ' $tags) | ||
set -l matches (string match -r 'v\d+\.\d+\.\d+' $tag) | ||
if test $matches | ||
set latest_version $tag | ||
break | ||
end | ||
end | ||
|
||
set -l matches (string match -r '(\d+)\.(\d+)\.(\d+)' $latest_version) | ||
set -l major $matches[2] | ||
set -l minor $matches[3] | ||
set -l patch $matches[4] | ||
|
||
if set -lq _flag_patch _flag_p | ||
echo v{$major}.{$minor}.(math $patch + 1) | ||
return | ||
else if set -lq _flag_minor _flag_m | ||
echo v{$major}.(math $minor + 1).0 | ||
return | ||
else if set -lq _flag_major _flag_M | ||
echo v(math $major + 1).0.0 | ||
return | ||
else | ||
echo 'Specify one of major|minor|patch as option' | ||
return 1 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# age initialization hook | ||
# | ||
# You can use the following variables in this file: | ||
# * $package package name | ||
# * $path package path | ||
# * $dependencies package dependencies |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# age uninstall hook | ||
# | ||
# You can use this file to do custom cleanup when the package is uninstalled. | ||
# You can use the variable $path to access the package path. |