Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
# RELEASE HISTORY

## Unreleased (1.11.0)

VCLog's commands are now subcommands of `vclog`, in place of an
executable each.

Changes:

* Add `vclog version`, `vclog bump`, `vclog news`, `vclog formats` and
`vclog autotag`, which do what `vclog-version`, `vclog-bump`,
`vclog-news`, `vclog-formats` and `vclog-autotag` did.
* Add `vclog log`, the same as plain `vclog`, and `vclog history`, the
same as `vclog -r`.
* Add `vclog help`, which lists the commands, and `vclog help COMMAND`.
* Deprecate the separate executables. They still work, and will be
removed in 2.0.
* A first argument that isn't a command or an option is now an error.
Before, it was ignored.
* Autotag puts a release's tag on the latest commit made on or before
its date in the history file, counting the whole of that day. Before,
it stopped at the start of the day, so a release committed on its
own date was tagged one commit early. Its prompt now shows the
commit the tag will go on.
* Fix the `--prefix` and `--file` options of autotag: the first took no
value and the second raised an error.


## 1.10.0 / 2026-11-24

The first release since 2012. It makes VCLog work on current Ruby (2.7
Expand Down
25 changes: 20 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@ To generate an a different format use -f:

### Creating Release Histories

To get a release history specify `-r`, `--release` or `--history` option.
To get a release history use the `history` command.

$ vclog -r
$ vclog history

The `-r`, `--release` or `--history` option of plain `vclog` does the
same.

Again the default format is an ANSI colored GNU-like text style.

Expand All @@ -47,26 +50,38 @@ message is used as the release note. If the underlying SCM doesn't
support tag messages than the message of the first commit prior to
the tag is used.

See `vclog --help` for more options.
See `vclog --help` for more options, and `vclog help` for the list of
commands.

### Bumping Versions

VCLog can also be used to intelligently bump versions. To see the current
tag version:

$ vclog-version
$ vclog version
1.1.0

To see the next reasonable version based on current changes:

$ vclog-bump
$ vclog bump
1.2.0

VCLog can determine the appropriate version based on commit level. Any
commit with a level greater than 1 will bump the major number, while any
commit with a level of 0 or 1 will bump the minor number. All lower
level only bump the patch level.

### Other Commands

$ vclog news # the latest release note in the History file
$ vclog autotag # tag each release in the History file not yet tagged
$ vclog formats # list the output formats
$ vclog help # list the commands

Before 1.11 these were separate executables: `vclog-version`,
`vclog-bump`, `vclog-news`, `vclog-formats` and `vclog-autotag`. Those
still work, but are deprecated and will be removed in 2.0.

### Writing Heuristics

VCLog can be configured to support custom log heuristics to suite the work flow
Expand Down
10 changes: 10 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# TODO

## For 2.0

* Remove the deprecated executables `vclog-version`, `vclog-bump`,
`vclog-news`, `vclog-formats` and `vclog-autotag` (the files in
`bin/`, the "Deprecated Commands" feature in
`spec/feature_commands.rb`, and the mentions in the README and
`man/man1/vclog.1.ronn`). They were deprecated in 1.11.0, when their
work moved to subcommands: `vclog version`, `vclog bump`, and so on.
5 changes: 2 additions & 3 deletions bin/vclog
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env ruby

require 'vclog/cli/log'

VCLog::CLI::Log.run(ARGV)
require 'vclog/cli'

VCLog::CLI.run(ARGV)
5 changes: 3 additions & 2 deletions bin/vclog-autotag
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env ruby

require 'vclog/cli/autotag'
# Deprecated: use `vclog autotag`. Kept so that existing scripts go on working.

VCLog::CLI::Autotag.run(ARGV)
require 'vclog/cli'

VCLog::CLI.run(['autotag'] + ARGV)
5 changes: 3 additions & 2 deletions bin/vclog-bump
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env ruby

require 'vclog/cli/bump'
# Deprecated: use `vclog bump`. Kept so that existing scripts go on working.

VCLog::CLI::Bump.run(ARGV)
require 'vclog/cli'

VCLog::CLI.run(['bump'] + ARGV)
5 changes: 3 additions & 2 deletions bin/vclog-formats
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env ruby

require 'vclog/cli/formats'
# Deprecated: use `vclog formats`. Kept so that existing scripts go on working.

VCLog::CLI::Formats.run(ARGV)
require 'vclog/cli'

VCLog::CLI.run(['formats'] + ARGV)
5 changes: 3 additions & 2 deletions bin/vclog-news
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env ruby

require 'vclog/cli/news'
# Deprecated: use `vclog news`. Kept so that existing scripts go on working.

VCLog::CLI::News.run(ARGV)
require 'vclog/cli'

VCLog::CLI.run(['news'] + ARGV)
5 changes: 3 additions & 2 deletions bin/vclog-version
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env ruby

require 'vclog/cli/version'
# Deprecated: use `vclog version`. Kept so that existing scripts go on working.

VCLog::CLI::Version.run(ARGV)
require 'vclog/cli'

VCLog::CLI.run(['version'] + ARGV)
88 changes: 88 additions & 0 deletions lib/vclog/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,93 @@
require 'vclog/cli/formats'
require 'vclog/cli/bump'
require 'vclog/cli/version'
require 'vclog/cli/news'
require 'vclog/cli/autotag'

module VCLog

# The `vclog` command line. The first argument can name a command;
# without one, a change log is printed.
#
# vclog [log] [options]
# vclog history [options]
# vclog version
# vclog bump
# vclog news
# vclog formats
# vclog autotag [options]
# vclog help [command]
#
module CLI

# What each command does, in the order they are listed by `help`.
COMMANDS = [
['log', Log, 'print a change log (the default)'],
['history', Log, 'print a release history'],
['version', Version, 'print the current version'],
['bump', Bump, 'print the next version, judging by the changes'],
['news', News, 'print the latest release note of the history file'],
['formats', Formats, 'list the output formats'],
['autotag', Autotag, 'tag each release in the history file not yet tagged']
]

# Other names a command answers to.
ALIASES = { 'changelog'=>'log', 'release'=>'history', 'templates'=>'formats' }

#
# Run the command line.
#
def self.run(argv=ARGV)
argv = argv.dup
name = ALIASES[argv.first] || argv.first

case name
when 'help'
argv.shift
help(argv.first)
when 'history'
argv.shift
Log.run(['--history'] + argv)
else
command = COMMANDS.find{ |term, _, _| term == name }
if command
argv.shift
command[1].run(argv)
elsif name && name !~ /\A-/
$stderr.puts "vclog: unknown command -- #{name}"
$stderr.puts "Try `vclog help`."
exit(-1)
else
Log.run(argv)
end
end
end

#
# Print the list of commands, or the help of one of them.
#
def self.help(name=nil)
name = ALIASES[name] || name
command = COMMANDS.find{ |term, _, _| term == name }
if command
command[1].run(name == 'history' ? ['--history', '--help'] : ['--help'])
elsif name
$stderr.puts "vclog: unknown command -- #{name}"
exit(-1)
else
puts "Usage: vclog [command] [options]"
puts
puts "COMMANDS:"
COMMANDS.each do |term, _, description|
puts " %-9s %s" % [term, description]
end
puts " %-9s %s" % ['help', 'show this list, or the options of a command']
puts
puts "With no command, a change log is printed. See `vclog help log`"
puts "for its options."
end
end

end

end
6 changes: 3 additions & 3 deletions lib/vclog/cli/autotag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ def self.terms
#
def parser
super do |opt|
opt.banner = "Usage: vclog autotag"
opt.banner = "Usage: vclog autotag [options]"
opt.separator(" ")
opt.separator("DESCRIPTION:")
opt.separator(" Ensure each entry in History has been tagged.")
opt.separator(" ")
opt.separator("SPECIAL OPTIONS:")
opt.on('--prefix', '-p', 'tag label prefix'){ options[:prefix] = true }
opt.on('--file' , '-f FILE', 'specify history file'){ options[:history_file] = file }
opt.on('--prefix', '-p PREFIX', 'tag label prefix'){ |prefix| options[:prefix] = prefix }
opt.on('--file' , '-f FILE', 'specify history file'){ |file| options[:history_file] = file }
opt.on('--force' , '-y', 'perform tagging without confirmation'){ options[:force] = true }
opt.on('--dryrun', '-n', 'run in dryrun mode'){ $DRYRUN = true }
end
Expand Down
2 changes: 1 addition & 1 deletion lib/vclog/cli/bump.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def self.terms
#
def parser
super do |opt|
opt.banner = "Usage: vclog-bump"
opt.banner = "Usage: vclog bump"
opt.separator(" ")
opt.separator("Display a bumped version number.")
end
Expand Down
4 changes: 3 additions & 1 deletion lib/vclog/cli/formats.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ def self.terms
#
def parser
super do |opt|
opt.banner = "Usage: vclog-formats"
opt.banner = "Usage: vclog formats"
opt.separator(" ")
opt.separator("List the output formats.")
end
end

Expand Down
3 changes: 2 additions & 1 deletion lib/vclog/cli/log.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ class Log < Abstract
# Returns a instance of OptionParser.
def parser
super do |parser|
parser.banner = 'Usage: vclog [options]'
parser.banner = 'Usage: vclog [log|history] [options]'
parser.separator(' ')
parser.separator('Print a change log or release history.')
parser.separator('See `vclog help` for the other commands.')
parser.separator(' ')
parser.separator('OPTIONS: (use varies with format)')
parser.on('-f', '--format FORMAT', 'output format (ansi,gnu,html,...)') do |format|
Expand Down
2 changes: 1 addition & 1 deletion lib/vclog/cli/news.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def self.terms
#
def parser
super do |opt|
opt.banner = "Usage: vclog-news"
opt.banner = "Usage: vclog news"
opt.separator(" ")
opt.separator("Display first release note from history file.")
end
Expand Down
19 changes: 14 additions & 5 deletions lib/vclog/repo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,16 @@ def history_file

#
# Read history file and make a commit tag for any release not already
# tagged. Unless the force option is set the user will be prompted for
# tagged, on the latest commit made on or before the release's date. Unless the force option is set the user will be prompted for
# each new tag.
#
def autotag(prefix=nil)
history_file.tags.each do |tag|
label = "#{prefix}#{tag.name}"
if not adapter.tag?(label)
chg = adapter.change_by_date(tag.date)
chg = adapter.change_by_date(end_of_day(tag.date))
if chg
if force? or ask_yn(new_tag_message(label, tag) + "\nCreate tag? [yN] ")
if force? or ask_yn(new_tag_message(label, tag, chg) + "\nCreate tag? [yN] ")
adapter.tag(chg.rev, label, tag.date, tag.message)
end
else
Expand Down Expand Up @@ -281,8 +281,17 @@ def ask_yn(message)
#
# Returns a String.
#
def new_tag_message(label, tag)
"#{label} / #{tag.date.strftime('%Y-%m-%d')}\n#{tag.message}"
def new_tag_message(label, tag, change)
"#{label} / #{tag.date.strftime('%Y-%m-%d')}\n#{tag.message}\n" +
"on commit #{change.id.to_s[0,7]} #{change.date.strftime('%Y-%m-%d %H:%M')} #{change.summary}"
end

#
# The last second of the day a time falls in. A release dated in the
# history file takes in the commits made during that day.
#
def end_of_day(time)
::Time.new(time.year, time.month, time.day, 23, 59, 59)
end

end
Expand Down
2 changes: 1 addition & 1 deletion lib/vclog/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module VCLog
VERSION = '1.10.0'
VERSION = '1.11.0'
end
2 changes: 0 additions & 2 deletions man/man1/index.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# manuals
vclog(1) vclog.1.ronn
vclog-changelog(1) vclog-changelog.1.ronn
vclog-history(1) vclog-history.1.ronn
vclog-version(1) vclog-version.1.ronn
vclog-news(1) vclog-news.1.ronn
vclog-bump(1) vclog-bump.1.ronn
Expand Down
2 changes: 1 addition & 1 deletion man/man1/vclog-autotag.1.ronn
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ vclog-autotag(1) - tag history entries

## SYNOPSIS

`vclog-autotag`
`vclog autotag`

## DESCRIPTION

Expand Down
2 changes: 1 addition & 1 deletion man/man1/vclog-bump.1.ronn
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ vclog-bump(1) - suggest next version

## SYNOPSIS

`vclog-bump`
`vclog bump`

## DESCRIPTION

Expand Down
Loading
Loading