Skip to content

Commit

Permalink
Renamed script from wincrementor to plusbump. close Praqma#1.
Browse files Browse the repository at this point in the history
I consider this a new feature, and thus a +minor.
No functionality was changed at all.
Readme was updated to match and cleaned up slightly.
  • Loading branch information
JKrag committed Nov 9, 2017
1 parent 5cee1cf commit 3bad25d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 43 deletions.
46 changes: 22 additions & 24 deletions README.md
Expand Up @@ -5,60 +5,58 @@ maintainer: jkrag

### Initial "requirement" description

Look at all commits between <ref> and HEAD.
Look at all commits between <ref> and HEAD.

Look for commit-message mentions of +major or +minor (unless different patterns where specified ). +patch is implicit as the default if none of the others where specified.
If a version string was speciefied bump the provided semver string correctly
i.e. increase the highest bumped level, and reset those below to 0.

If a version string was specified, bump the provided semver string correctly.
I.e. increase the highest bumped level, and reset those below to 0.

Currently, the bump leaves any part of semver after `-` intact (e.g. 1.3.14-alpha3+as34df32), but I reserve the right to change my mind on this :-D

If no version string was specified bump the version 0.0.0, i.e. return either 1.0.0, 0.1.0 or 0.0.1

### Other features
The tool already supports a few more features:

```
Wincrementor 1.2
Usage:
wincrementor.rb --latest=<tag-glob> [<semver_version_string>] [options]
wincrementor.rb <ref> [<semver_version_string>] [options]
wincrementor.rb -h|--help
root@6bd83c9d7335:/data# ruby wincrementor.rb -h
Wincrementor 1.2
PlusBump 1.3
Usage:
wincrementor.rb --latest=<tag-glob> [<semver_version_string>] [options]
wincrementor.rb <ref> [<semver_version_string>] [options]
wincrementor.rb -h|--help
./plusbump.rb --latest=<tag-glob> [<semver_version_string>] [options]
./plusbump.rb <ref> [<semver_version_string>] [options]
./plusbump.rb -h|--help
Options:
-h --help Show this screen.
-t --tag-commit Actually tag HEAD with the version number computed.
-l --latest=<tag-glob>
-l --latest=<tag-glob>
Specify a glob pattern to search for last matching tag instead of
providing a specific ref.
Will attempt to use everything after <tag-glob> as the version string
so be sure to provide _entire_ prefix.
so be sure to provide _entire_ prefix.
E.g. use "R_" if your versions are "R_1.2.3"
-p --prefix=<prefix>
-p --prefix=<prefix>
Specify a prefix to add before the resulting version string
-s --special=<postfix>
Specify the "special" part of the resulting version string. This is any part of the version string that comes after the dash, e.g. in 1.3.4-SNAPSHOT it is the string "SNAPSHOT". Note this is for the "output" side. Wincrementor will accept any special string on the input and preserve it, unless you specify `--special=""` or something else.
Specify the "special" part of the resulting version string.
This is any part of the version string that comes after the dash,
e.g. in 1.3.4-SNAPSHOT it is the string "SNAPSHOT".
Note this is for the "output" side.
PlusBump will accept any special string on the input and preserve it,
unless you specify `--special=""` or something else.
-a --majorpattern=<major_pattern>
Specify an alternative (regex) pattern that indicates a major version bump.
E.g. --majorpattern='\+major'
-i --minorpattern=<minor_pattern>
Specify an alternative (regex) pattern that indicates a minor version bump.
Expand All @@ -69,10 +67,10 @@ Options:
### Helping users
If you decide to require bumps on every commit (e.g. instead of assuming +patch as default), then it can be very helpful to users set up a push hook (pre-receive on Git) that rejects commits without a bump.

I have succesfully done this on BitBucket using the "Jira Hooks for BitBucket" plugin (that we were using anyway), and used the following regex:
I have successfully done this on BitBucket using the "Jira Hooks for BitBucket" plugin (that we were using anyway), and used the following regex:
```
(^|(.|\n)*\s)\+(major|minor|patch)($|\s(.|\n)*)
```

This RegEx should also be quite usable in other plugins or handwritten hooks as it does not require multiline or other swithes to be supported.
This RegEx should also be quite usable in other plugins or handwritten hooks as it does not require multiline or other switches to be supported.
It allows the `+bump` message to appear anywhere in the commit message as long as it is not adjacent to other text. (i.e. `my+patch` and `+patching` will be rejected.
38 changes: 19 additions & 19 deletions wincrementor.rb → plusbump.rb
Expand Up @@ -14,49 +14,49 @@
Options:
-h --help Show this screen.
-t --tag-commit Actually tag HEAD with the version number computed.
-l --latest=<tag-glob>
-l --latest=<tag-glob>
Specify a glob pattern to search for last matching tag instead of
providing a specific ref.
Will attempt to use everything after <tag-glob> as the version string
so be sure to provide _entire_ prefix.
so be sure to provide _entire_ prefix.
E.g. use "R_" if your versions are "R_1.2.3"
-p --prefix=<prefix>
-p --prefix=<prefix>
Specify a prefix to add before the resulting version string
-s --special=<postfix>
Specify the "special" part of the resulting version string.
This is any part of the version string that comes after the dash,
e.g. in 1.3.4-SNAPSHOT it is the string "SNAPSHOT".
Note this is for the "output" side.
Wincrementor will accept any special string on the input and preserve it,
Specify the "special" part of the resulting version string.
This is any part of the version string that comes after the dash,
e.g. in 1.3.4-SNAPSHOT it is the string "SNAPSHOT".
Note this is for the "output" side.
PlusBump will accept any special string on the input and preserve it,
unless you specify `--special=""` or something else.
-a --majorpattern=<major_pattern>
Specify an alternative (regex) pattern that indicates a major version bump.
E.g. --majorpattern='\\+major'
-i --minorpattern=<minor_pattern>
Specify an alternative (regex) pattern that indicates a minor version bump.
E.g. --minorpattern='\\+minor'
DOCOPT

# Note: If you are reading the above usage in the source code and not using --help,
# then ignore the double escapes in the usage examples.
# Note: If you are reading the above usage in the source code and not using --help,
# then ignore the double escapes in the usage examples.
# On the command line you have to write --majorpattern='\+major'
# The extra escape is to make it print that way in the usage message.

begin
input = Docopt::docopt(doc)

#puts input
#puts input
debug = false

# Defaults
Expand All @@ -83,9 +83,9 @@
majorpatternstring = input['--minorpattern']
major = Regexp.new(majorpatternstring)
end

# Init Repo from current directory
repository = Rugged::Repository.new(Dir.pwd)
repository = Rugged::Repository.new(Dir.pwd)
tagcollection = Rugged::TagCollection.new(repository)


Expand Down Expand Up @@ -134,11 +134,11 @@
# end


if !input['--special'].nil?
if !input['--special'].nil?
s = input['--special']
if s.empty?
special = ''
else
else
special = '-'+ s
end
end
Expand Down Expand Up @@ -177,7 +177,7 @@
elsif patch_bump
result.patch += 1
else
puts "No version increment"
puts "No version increment"
end

final_res = prefix + (result.format "%M.%m.%p%s")
Expand All @@ -190,7 +190,7 @@
puts final_res

rescue Docopt::Exit => e
puts "Wincrementor 1.2"
puts "PlusBump 1.3"
puts ""
puts e.message
end

0 comments on commit 3bad25d

Please sign in to comment.