diff --git a/.gemspec b/.gemspec
deleted file mode 100644
index 8137c9b..0000000
--- a/.gemspec
+++ /dev/null
@@ -1,306 +0,0 @@
-# encoding: utf-8
-
-require 'yaml'
-require 'pathname'
-
-module Indexer
-
- # Convert index data into a gemspec.
- #
- # Notes:
- # * Assumes all executables are in bin/.
- # * Does not yet handle default_executable setting.
- # * Does not yet handle platform setting.
- # * Does not yet handle required_ruby_version.
- # * Support for rdoc entries is weak.
- #
- class GemspecExporter
-
- # File globs to include in package (unless manifest file exists).
- FILES = ".index .ruby .yardopts alt bin ext lib man spec test [A-Z]*.*" unless defined?(FILES)
-
- # File globs to omit.
- OMIT = "Config.rb" unless defined?(OMIT)
-
- # Standard file patterns.
- PATTERNS = {
- :root => '{.index,Gemfile}',
- :bin => 'bin/*',
- :lib => 'lib/{**/}*', #.rb',
- :ext => 'ext/{**/}extconf.rb',
- :doc => '*.{txt,rdoc,md,markdown,tt,textile}',
- :test => '{test,spec}/{**/}*.rb'
- } unless defined?(PATTERNS)
-
- # For which revision of indexer spec is this converter intended?
- REVISION = 2013 unless defined?(REVISION)
-
- #
- def self.gemspec
- new.to_gemspec
- end
-
- #
- attr :metadata
-
- #
- def initialize(metadata=nil)
- @root_check = false
-
- if metadata
- root_dir = metadata.delete(:root)
- if root_dir
- @root = root_dir
- @root_check = true
- end
- metadata = nil if metadata.empty?
- end
-
- @metadata = metadata || YAML.load_file(root + '.index')
-
- if @metadata['revision'].to_i != REVISION
- warn "This gemspec exporter was not designed for this revision of index metadata."
- end
- end
-
- #
- def has_root?
- root ? true : false
- end
-
- #
- def root
- return @root if @root || @root_check
- @root_check = true
- @root = find_root
- end
-
- #
- def manifest
- return nil unless root
- @manifest ||= Dir.glob(root + 'manifest{,.txt}', File::FNM_CASEFOLD).first
- end
-
- #
- def scm
- return nil unless root
- @scm ||= %w{git hg}.find{ |m| (root + ".#{m}").directory? }.to_sym
- end
-
- #
- def files
- return [] unless root
- @files ||= \
- if manifest
- File.readlines(manifest).
- map{ |line| line.strip }.
- reject{ |line| line.empty? || line[0,1] == '#' }
- else
- list = []
- Dir.chdir(root) do
- FILES.split(/\s+/).each do |pattern|
- list.concat(glob(pattern))
- end
- OMIT.split(/\s+/).each do |pattern|
- list = list - glob(pattern)
- end
- end
- list
- end.select{ |path| File.file?(path) }.uniq
- end
-
- #
- def glob_files(pattern)
- return [] unless root
- Dir.chdir(root) do
- Dir.glob(pattern).select do |path|
- File.file?(path) && files.include?(path)
- end
- end
- end
-
- def patterns
- PATTERNS
- end
-
- def executables
- @executables ||= \
- glob_files(patterns[:bin]).map do |path|
- File.basename(path)
- end
- end
-
- def extensions
- @extensions ||= \
- glob_files(patterns[:ext]).map do |path|
- File.basename(path)
- end
- end
-
- def name
- metadata['name'] || metadata['title'].downcase.gsub(/\W+/,'_')
- end
-
- def homepage
- page = (
- metadata['resources'].find{ |r| r['type'] =~ /^home/i } ||
- metadata['resources'].find{ |r| r['name'] =~ /^home/i } ||
- metadata['resources'].find{ |r| r['name'] =~ /^web/i }
- )
- page ? page['uri'] : false
- end
-
- def licenses
- metadata['copyrights'].map{ |c| c['license'] }.compact
- end
-
- def require_paths
- metadata['load_path'] || ['lib']
- end
-
- #
- # Convert to gemnspec.
- #
- def to_gemspec
- if has_root?
- Gem::Specification.new do |gemspec|
- to_gemspec_data(gemspec)
- to_gemspec_paths(gemspec)
- end
- else
- Gem::Specification.new do |gemspec|
- to_gemspec_data(gemspec)
- to_gemspec_paths(gemspec)
- end
- end
- end
-
- #
- # Convert pure data settings.
- #
- def to_gemspec_data(gemspec)
- gemspec.name = name
- gemspec.version = metadata['version']
- gemspec.summary = metadata['summary']
- gemspec.description = metadata['description']
-
- metadata['authors'].each do |author|
- gemspec.authors << author['name']
-
- if author.has_key?('email')
- if gemspec.email
- gemspec.email << author['email']
- else
- gemspec.email = [author['email']]
- end
- end
- end
-
- gemspec.licenses = licenses
-
- requirements = metadata['requirements'] || []
- requirements.each do |req|
- next if req['optional']
- next if req['external']
-
- name = req['name']
- groups = req['groups'] || []
-
- version = gemify_version(req['version'])
-
- if groups.empty? or groups.include?('runtime')
- # populate runtime dependencies
- if gemspec.respond_to?(:add_runtime_dependency)
- gemspec.add_runtime_dependency(name,*version)
- else
- gemspec.add_dependency(name,*version)
- end
- else
- # populate development dependencies
- if gemspec.respond_to?(:add_development_dependency)
- gemspec.add_development_dependency(name,*version)
- else
- gemspec.add_dependency(name,*version)
- end
- end
- end
-
- # convert external dependencies into gemspec requirements
- requirements.each do |req|
- next unless req['external']
- gemspec.requirements << ("%s-%s" % req.values_at('name', 'version'))
- end
-
- gemspec.homepage = homepage
- gemspec.require_paths = require_paths
- gemspec.post_install_message = metadata['install_message']
- end
-
- #
- # Set gemspec settings that require a root directory path.
- #
- def to_gemspec_paths(gemspec)
- gemspec.files = files
- gemspec.extensions = extensions
- gemspec.executables = executables
-
- if Gem::VERSION < '1.7.'
- gemspec.default_executable = gemspec.executables.first
- end
-
- gemspec.test_files = glob_files(patterns[:test])
-
- unless gemspec.files.include?('.document')
- gemspec.extra_rdoc_files = glob_files(patterns[:doc])
- end
- end
-
- #
- # Return a copy of this file. This is used to generate a local
- # .gemspec file that can automatically read the index file.
- #
- def self.source_code
- File.read(__FILE__)
- end
-
- private
-
- def find_root
- root_files = patterns[:root]
- if Dir.glob(root_files).first
- Pathname.new(Dir.pwd)
- elsif Dir.glob("../#{ROOT}").first
- Pathname.new(Dir.pwd).parent
- else
- #raise "Can't find root of project containing `#{root_files}'."
- warn "Can't find root of project containing `#{root_files}'."
- nil
- end
- end
-
- def glob(pattern)
- if File.directory?(pattern)
- Dir.glob(File.join(pattern, '**', '*'))
- else
- Dir.glob(pattern)
- end
- end
-
- def gemify_version(version)
- case version
- when /^(.*?)\+$/
- ">= #{$1}"
- when /^(.*?)\-$/
- "< #{$1}"
- when /^(.*?)\~$/
- "~> #{$1}"
- else
- version
- end
- end
-
- end
-
-end
-
-Indexer::GemspecExporter.gemspec
\ No newline at end of file
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..92168df
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,30 @@
+name: CI
+
+on:
+ push:
+ pull_request:
+ workflow_dispatch:
+ # Monthly, to catch breakage from new Ruby or dependency releases
+ # when nothing has been pushed.
+ schedule:
+ - cron: '0 6 1 * *'
+
+permissions:
+ contents: read
+
+jobs:
+ test:
+ name: Ruby ${{ matrix.ruby }}
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ ruby: ['2.7', '3.0', '3.1', '3.2', '3.3', '3.4', '4.0']
+ steps:
+ - uses: actions/checkout@v4
+ - uses: ruby/setup-ruby@v1
+ with:
+ ruby-version: ${{ matrix.ruby }}
+ bundler-cache: true
+ - name: Tests
+ run: bundle exec rake test
diff --git a/.index b/.index
deleted file mode 100644
index cefb5f9..0000000
--- a/.index
+++ /dev/null
@@ -1,68 +0,0 @@
----
-revision: 2013
-type: ruby
-sources:
-- index
-authors:
-- name: Trans
- email: transfire@gmail.com
-organizations: []
-requirements:
-- version: ! '>= 2.4'
- name: facets
-- version: ! '>= 1.2'
- name: ansi
-- name: xml-simple
-- groups:
- - build
- development: true
- name: detroit
-- groups:
- - build
- development: true
- name: ergo
-- groups:
- - test
- development: true
- name: citron
-- groups:
- - test
- development: true
- name: lime
-- groups:
- - test
- development: true
- name: ae
-- groups:
- - test
- development: true
- name: rubytest-cli
-conflicts: []
-alternatives: []
-resources:
-- type: home
- uri: http://rubyworks.github.com/vclog
- label: Homepage
-- type: code
- uri: http://github.com/rubyworks/vclog
- label: Source Code
-repositories:
-- name: upstream
- scm: git
- uri: git://github.com/rubyworks/vclog.git
-categories: []
-copyrights:
-- holder: Rubyworks
- year: '2009'
- license: BSD-2-Clause
-customs: []
-paths:
- lib:
- - lib
-created: '2006-05-09'
-summary: Cross-VCS/SCM ChangeLog Generator
-title: VCLog
-version: 1.9.3
-name: vclog
-description: VCLog is a cross-VCS/SCM ChangeLog generator.
-date: '2013-03-03'
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 72f1981..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,8 +0,0 @@
----
-script: "bundle exec rubytest test/"
-rvm:
- - 1.9.2
- - 1.9.3
- - rbx-19mode
- - jruby-19mode
-
diff --git a/Assembly b/Assembly
deleted file mode 100644
index d3822c1..0000000
--- a/Assembly
+++ /dev/null
@@ -1,46 +0,0 @@
----
-email:
- mailto:
- - ruby-talk@ruby-lang.org
- - rubyworks-mailinglist@googlegroups.com
-
-gem:
- active: true
-
-github:
- folder: web
-
-dnote:
- title: Source Notes
- output: log/notes.html
- files: lib/**/*.rb
-
-locat:
- output: log/locat.html
-
-vclog:
- output:
- - log/history.html
- - log/changes.html
- - web/eg/history.html
- - web/eg/changes.html
- - web/eg/history.rdoc
- - web/eg/changes.rdoc
- - web/eg/history.atom
- - web/eg/changes.atom
- - web/eg/history.rss
- - web/eg/changes.rss
-
-ronn:
- service : custom
- cycle : main
- document : |
- system 'ronn --manual="VCLog" --organization="RubyWorks" --style="toc" man/man1/*.ronn'
- system 'cp man/man1/*.html web/man/'
-
-#ronn:
-# path: man/man1/*.ronn
-# title: VCLog
-# style: toc
-# organization: Rubyworks
-
diff --git a/History.md b/History.md
index 735d762..9a6eca4 100644
--- a/History.md
+++ b/History.md
@@ -1,14 +1,41 @@
# RELEASE HISTORY
-## 1.9.3 / 2012-04-09
+## Unreleased (1.10.0)
-This release should finally fix issue #14. If also adds support
-for RC based configuration.
+The first release since 2012. It makes VCLog work on current Ruby (2.7
+to 4.0) and with current Facets, RDoc and Git, and fixes a number of
+long-standing bugs. Version 1.9.3 was prepared in 2012 but never
+released; its changes are included here.
Changes:
-* Fix issue #14.
-* Add support for RC.
+* Fix loading with Facets 4, which no longer has `String#tabto` or
+ `Enumerable#group_by` files. (#18)
+* Fix release histories putting a tagged commit in the release after
+ its own. (#16)
+* Fix reading of Git tags: a tag message beginning with a letter from
+ a to f, or a long one, could break `vclog -r`, `vclog-version` and
+ `vclog-bump`. (#15)
+* Fix a crash on Git commits that change no files, and on commits and
+ tags with an empty message. (#17, thanks to Christopher Fuhrman)
+* The current version is the highest version tag, so 0.10.0 comes
+ after 0.9.0, where before it was the last tag by name.
+* `-p` (`--point`) now splits commit messages into points and the
+ default doesn't; the two were the wrong way round.
+* Find the history file whatever its case (`History.md`, `HISTORY.md`).
+* Find a project's config file (`etc/vclog.rb`, `config/vclog.rb`,
+ `.vclog`, ...), which the last code on master failed to do.
+* Fix the HTML format with current RDoc, and ERB templates on Ruby 3.
+* Fix `Heuristics.eval` and `Heuristics#level`, which raised errors.
+* Error messages go to standard error.
+* Git commands are run without a shell.
+* Depend on `ostruct`, `json` and `rdoc`, which are no longer always
+ part of Ruby.
+* Remove the RC configuration support that was added for 1.9.3 and
+ deprecated before any release.
+* Tests run on Spectrum and Assay, against a Git repository built for
+ the purpose, and check what the commands print. Before, they needed
+ the network and didn't check anything.
## 1.9.2 / 2012-03-03
diff --git a/Manifest.txt b/Manifest.txt
deleted file mode 100644
index d09390a..0000000
--- a/Manifest.txt
+++ /dev/null
@@ -1,88 +0,0 @@
-#!mast .ruby .yardopts bin features lib man spec test [A-Z]*.*
-.ruby
-.yardopts
-bin/vclog
-bin/vclog-autotag
-bin/vclog-bump
-bin/vclog-formats
-bin/vclog-news
-bin/vclog-version
-lib/vclog/adapters/abstract.rb
-lib/vclog/adapters/darcs.rb
-lib/vclog/adapters/git.rb
-lib/vclog/adapters/hg.rb
-lib/vclog/adapters/svn.rb
-lib/vclog/adapters.rb
-lib/vclog/change.rb
-lib/vclog/change_point.rb
-lib/vclog/changelog.rb
-lib/vclog/cli/abstract.rb
-lib/vclog/cli/autotag.rb
-lib/vclog/cli/bump.rb
-lib/vclog/cli/formats.rb
-lib/vclog/cli/log.rb
-lib/vclog/cli/news.rb
-lib/vclog/cli/version.rb
-lib/vclog/cli.rb
-lib/vclog/config.rb
-lib/vclog/core_ext.rb
-lib/vclog/heuristics/rule.rb
-lib/vclog/heuristics/type.rb
-lib/vclog/heuristics.rb
-lib/vclog/history_file.rb
-lib/vclog/metadata.rb
-lib/vclog/rc.rb
-lib/vclog/release.rb
-lib/vclog/repo.rb
-lib/vclog/report.rb
-lib/vclog/tag.rb
-lib/vclog/templates/changelog.ansi.rb
-lib/vclog/templates/changelog.atom.erb
-lib/vclog/templates/changelog.gnu.rb
-lib/vclog/templates/changelog.html.erb
-lib/vclog/templates/changelog.json.rb
-lib/vclog/templates/changelog.markdown.rb
-lib/vclog/templates/changelog.rdoc.rb
-lib/vclog/templates/changelog.rss.erb
-lib/vclog/templates/changelog.xml.erb
-lib/vclog/templates/changelog.xsl
-lib/vclog/templates/changelog.yaml.rb
-lib/vclog/templates/history.ansi.rb
-lib/vclog/templates/history.atom.erb
-lib/vclog/templates/history.gnu.rb
-lib/vclog/templates/history.html.erb
-lib/vclog/templates/history.json.rb
-lib/vclog/templates/history.markdown.rb
-lib/vclog/templates/history.rdoc.rb
-lib/vclog/templates/history.rss.erb
-lib/vclog/templates/history.xml.erb
-lib/vclog/templates/history.yaml.rb
-lib/vclog.rb
-lib/vclog.yml
-man/man1/index.txt
-man/man1/vclog-autotag.1
-man/man1/vclog-autotag.1.html
-man/man1/vclog-autotag.1.ronn
-man/man1/vclog-bump.1
-man/man1/vclog-bump.1.html
-man/man1/vclog-bump.1.ronn
-man/man1/vclog-news.1
-man/man1/vclog-news.1.html
-man/man1/vclog-news.1.ronn
-man/man1/vclog-version.1
-man/man1/vclog-version.1.html
-man/man1/vclog-version.1.ronn
-man/man1/vclog.1
-man/man1/vclog.1.html
-man/man1/vclog.1.ronn
-spec/feature_git_changes.rb
-spec/feature_git_history.rb
-spec/feature_hg_changes.rb
-spec/feature_hg_history.rb
-spec/featurettes/repo_creation.rb
-spec/featurettes/shellout.rb
-test/case_metadata.rb
-README.md
-History.md
-License.txt
-Config.rb
diff --git a/README.md b/README.md
index f9ccc0e..92fbea7 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,8 @@
# VCLog
-[Website](http://rubyworks.github.com/vclog) /
-[Report Issue](http://github.com/rubyworks/vclog/issues) /
-[Source Code](http://github.com/rubyworks/vclog)
-[](http://travis-ci.org/rubyworks/vclog)
+[Report Issue](https://github.com/rubyworks/vclog/issues) /
+[Source Code](https://github.com/rubyworks/vclog)
+[](https://github.com/rubyworks/vclog/actions/workflows/ci.yml)
**VCLog is a versatile and customizable cross-VCS/SCM changelog and release history generator.**
@@ -17,6 +16,9 @@ It currently supports the following Version Control Systems:
* Subversion
Subversion support is limited however. See Limitations noted below.
+Only Git is covered by the test suite at present.
+
+VCLog needs Ruby 2.7 or newer.
## Instructions
@@ -28,10 +30,6 @@ From a repository's root directory try:
$ vclog
-The is the same as specifying 'changelog' or 'log'.
-
- $ vclog log
-
To generate an a different format use -f:
$ vclog -f xml
@@ -49,7 +47,7 @@ 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.
### Bumping Versions
@@ -123,7 +121,7 @@ idea how to remedy this issue. If you have any ideas please let me know.
## Copyrights
-VCLog (http://rubyworks.github.com/vclog)
+VCLog (https://github.com/rubyworks/vclog)
Copyright © 2008 Rubyworks. All rights reserved.
diff --git a/Rakefile b/Rakefile
index af87277..ab97c5e 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,21 +1,29 @@
-#!/usr/bin/env ruby
+require 'rake/clean'
+CLOBBER.include 'pkg'
-#require 'cucumber'
-#require 'cucumber/rake/task'
+require 'bundler/gem_helper'
-#::Cucumber::Rake::Task.new(:features) do |t|
-# t.cucumber_opts = "features --format pretty"
-#end
+# Bundler tags releases as v1.2.3, but VCLog's tags have always been
+# plain version numbers, so keep it that way.
+class Bundler::GemHelper
+ def version_tag
+ version.to_s
+ end
+end
-task :default => [:test]
+Bundler::GemHelper.install_tasks
-desc "run lime specifications"
-task :spec do
- sh 'rubytest'
+desc 'run unit tests'
+task 'test:unit' do
+ sh 'rubytest -Ilib -r spectrum/testcase -r ./test/helper test/case_*.rb'
end
-desc "run lime specifications (same as spec)"
-task :test do
- sh 'rubytest'
+desc 'run features'
+task 'test:features' do
+ sh 'rubytest -Ilib -r spectrum/feature -r ./test/helper spec/feature_*.rb'
end
+desc 'run all tests'
+task 'test' => ['test:unit', 'test:features']
+
+task 'default' => 'test'
diff --git a/etc/test.rb b/etc/test.rb
deleted file mode 100644
index c4afd27..0000000
--- a/etc/test.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/usr/bin/env ruby
-
-Test.run :default do |run|
- require 'citron'
- require 'ae'
-
- run.files << 'test/case_*.rb'
-end
-
-Test.run :spec do |run|
- require 'lime'
- require 'ae'
-
- run.files << 'spec/feature_*.rb'
-end
-
diff --git a/index/authors b/index/authors
deleted file mode 100644
index d375be2..0000000
--- a/index/authors
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- Trans
diff --git a/index/copyrights b/index/copyrights
deleted file mode 100644
index df80b1b..0000000
--- a/index/copyrights
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- (c) 2009 Rubyworks (BSD-2-Clause)
diff --git a/index/created b/index/created
deleted file mode 100644
index b296f82..0000000
--- a/index/created
+++ /dev/null
@@ -1 +0,0 @@
-2006-05-09
\ No newline at end of file
diff --git a/index/description b/index/description
deleted file mode 100644
index e55dec5..0000000
--- a/index/description
+++ /dev/null
@@ -1 +0,0 @@
-VCLog is a cross-VCS/SCM ChangeLog generator.
\ No newline at end of file
diff --git a/index/name b/index/name
deleted file mode 100644
index ab9faac..0000000
--- a/index/name
+++ /dev/null
@@ -1 +0,0 @@
-vclog
\ No newline at end of file
diff --git a/index/organization b/index/organization
deleted file mode 100644
index bb7d645..0000000
--- a/index/organization
+++ /dev/null
@@ -1 +0,0 @@
-Rubyworks
\ No newline at end of file
diff --git a/index/repositories b/index/repositories
deleted file mode 100644
index c371bd7..0000000
--- a/index/repositories
+++ /dev/null
@@ -1,2 +0,0 @@
----
-upstream: git://github.com/rubyworks/vclog.git
diff --git a/index/requirements b/index/requirements
deleted file mode 100644
index 92b6f12..0000000
--- a/index/requirements
+++ /dev/null
@@ -1,11 +0,0 @@
----
-- facets >= 2.4
-- ansi >= 1.2
-- xml-simple
-- detroit (build)
-- ergo (build)
-- citron (test)
-- lime (test)
-- ae (test)
-- rubytest-cli (test)
-
diff --git a/index/resources b/index/resources
deleted file mode 100644
index 9eabae7..0000000
--- a/index/resources
+++ /dev/null
@@ -1,3 +0,0 @@
----
-home: http://rubyworks.github.com/vclog
-code: http://github.com/rubyworks/vclog
diff --git a/index/summary b/index/summary
deleted file mode 100644
index e20c3f1..0000000
--- a/index/summary
+++ /dev/null
@@ -1 +0,0 @@
-Cross-VCS/SCM ChangeLog Generator
\ No newline at end of file
diff --git a/index/title b/index/title
deleted file mode 100644
index 37b32e1..0000000
--- a/index/title
+++ /dev/null
@@ -1 +0,0 @@
-VCLog
\ No newline at end of file
diff --git a/index/version b/index/version
deleted file mode 100644
index 77fee73..0000000
--- a/index/version
+++ /dev/null
@@ -1 +0,0 @@
-1.9.3
diff --git a/lib/vclog.yml b/lib/vclog.yml
deleted file mode 120000
index f018114..0000000
--- a/lib/vclog.yml
+++ /dev/null
@@ -1 +0,0 @@
-../.index
\ No newline at end of file
diff --git a/lib/vclog/adapters/abstract.rb b/lib/vclog/adapters/abstract.rb
index 06ea87d..88a2b47 100644
--- a/lib/vclog/adapters/abstract.rb
+++ b/lib/vclog/adapters/abstract.rb
@@ -73,15 +73,10 @@ def tag?(name)
tags.find{ |t| t.name == name }
end
- # Returns the current verion string.
+ # Returns the current version string: the highest version tag.
def version
- if tags.last
- v = tags[-1].name # TODO: ensure the latest version
- v = tags[-2].name if v == 'HEAD'
- else
- v = '0.0.0'
- end
- return v
+ latest = tags.reject{ |t| t.name == 'HEAD' }.sort.first
+ latest ? latest.name : '0.0.0'
end
# Return the latest commit as of a given date.
diff --git a/lib/vclog/adapters/git.rb b/lib/vclog/adapters/git.rb
index 3df8408..6a47348 100644
--- a/lib/vclog/adapters/git.rb
+++ b/lib/vclog/adapters/git.rb
@@ -8,137 +8,83 @@ module Adapters
#
class Git < Abstract
- GIT_COMMIT_MARKER = '=====%n'
- GIT_FIELD_MARKER = '-----%n'
-
- RUBY_COMMIT_MARKER = "=====\n"
- RUBY_FIELD_MARKER = "-----\n"
+ # Fields and records are separated by control characters, which
+ # don't turn up in commit messages or file names.
+ FIELD = "\x1f"
+ RECORD = "\x1e"
# Collect changes, i.e. commits.
def extract_changes
- list = []
-
- command = 'git log --name-only --pretty=format:"' +
- GIT_COMMIT_MARKER +
- '%ci' +
- GIT_FIELD_MARKER +
- '%aN' +
- GIT_FIELD_MARKER +
- '%H' +
- GIT_FIELD_MARKER +
- '%s%n%n%b' +
- GIT_FIELD_MARKER +
- '"'
-
- changes = `#{command}`.split(RUBY_COMMIT_MARKER)
-
- changes.shift # throw the first (empty) entry away
-
- changes.each do |entry|
- date, who, id, msg, files = entry.split(RUBY_FIELD_MARKER)
- date = Time.parse(date)
- files = files.split("\n")
- list << Change.new(:id=>id, :date=>date, :who=>who, :msg=>msg, :files=>files)
+ format = ['%ci', '%aN', '%H', '%s%n%n%b', ''].join('%x1f')
+ output = git('log', '--name-only', "--pretty=format:%x1e#{format}")
+
+ output.split(RECORD).reject{ |entry| entry.strip.empty? }.map do |entry|
+ date, who, id, msg, files = entry.split(FIELD)
+ Change.new(
+ :id => id,
+ :date => Time.parse(date),
+ :who => who,
+ :msg => msg.to_s.strip,
+ :files => files.to_s.split("\n").reject{ |f| f.empty? }
+ )
end
+ end
- return list
- end
-
- #
- #def extract_files(change_list)
- # change_list.each do |change|
- # files = `git show --pretty="format:" --name-only #{c.id}`
- # files = files.split("\n")
- # change.files = files
- # end
- #end
-
- # Collect tags.
- #
- # `git show 1.0` produces:
- #
- # tag 1.0
- # Tagger: 7rans
- # Date: Sun Oct 25 09:27:58 2009 -0400
- #
- # version 1.0
- # commit
- # ...
- #
- # @todo This code is pretty poor, but it suffices for now.
- # And we need not worry about it the future b/c eventually
- # we will replace it by using the `amp` or `scm` gem.
+ # Collect tags. An annotated tag has its own author, date and
+ # message; a lightweight tag takes them from its commit.
def extract_tags
- list = []
- tags = `git tag -l`
- tags.split(/\s+/).each do |tag|
- next unless version_tag?(tag) # only version tags
- id, who, date, rev, msg = nil, nil, nil, nil, nil
- info = `git show #{tag}`
- info, *_ = info.split(/^(commit|diff|----)/)
- if /\Atag/ =~ info
- msg = ''
- info.lines.to_a[1..-1].each do |line|
- case line
- when /^Tagger:/
- who = $'.strip
- when /^Date:/
- date = $'.strip
- when /^\s*[a-f0-9]+/
- id = $0.strip
- else
- msg << line
- end
- end
- msg = msg.strip
-
- #info = `git show #{tag}^ --pretty=format:"%ci|~|%H|~|"`
- #cdate, id, *_ = *info.split('|~|')
-
- info = git_show("#{tag}")
+ format = %w[
+ %(refname:short) %(objecttype) %(objectname) %(*objectname)
+ %(taggername) %(taggeremail) %(taggerdate:iso8601) %(contents)
+ ].join('%1f') + '%1e'
- change = Change.new(info)
+ output = git('for-each-ref', "--format=#{format}", 'refs/tags')
- list << Tag.new(:id=>change.id, :name=>tag, :date=>date, :who=>who, :msg=>msg, :commit=>change)
- else
- #info = `git show #{tag} --pretty=format:"%cn|~|%ce|~|%ci|~|%H|~|%s|~|"`
- info = git_show(tag)
+ list = []
+ output.split(RECORD).each do |entry|
+ name, type, id, commit_id, who, email, date, msg = entry.sub(/\A\n/, '').split(FIELD)
+ next if name.nil? || name.empty?
+ next unless version_tag?(name) # only version tags
+
+ if type == 'tag'
+ next if commit_id.to_s.empty? # a tag of something other than a commit
+ change = Change.new(git_show(commit_id))
+ list << Tag.new(
+ :id => change.id,
+ :name => name,
+ :date => date,
+ :who => "#{who} #{email}".strip,
+ :msg => msg.to_s.strip,
+ :commit => change
+ )
+ elsif type == 'commit'
+ info = git_show(id)
change = Change.new(info)
-
- tag_info = {
- :name => tag,
+ list << Tag.new(
+ :name => name,
:who => info[:who],
:date => info[:date],
:msg => info[:message],
:commit => change
- }
- list << Tag.new(tag_info)
- end
-
- #if $DEBUG
- # p who, date, rev, msg
- # puts
- #end
-
- #list << tag
+ )
+ end
end
-
- return list
+ list
end
# User name of developer.
def user
- @user ||= `git config user.name`.strip
+ @user ||= git('config', 'user.name').strip
end
# Email address of developer.
def email
- @email ||= `git config user.email`.strip
+ @email ||= git('config', 'user.email').strip
end
#
def repository
- @repository ||= `git config remote.origin.url`.strip
+ @repository ||= git('config', 'remote.origin.url').strip
end
#
@@ -148,39 +94,31 @@ def tag(ref, label, date, message)
file = tempfile("message", message)
date = date.strftime('%Y-%m-%d 23:59') unless String===date
- cmd = %[GIT_AUTHOR_DATE='#{date}' GIT_COMMITTER_DATE='#{date}' git tag -a -F '#{file}' #{label} #{ref}]
- puts cmd if $DEBUG
- `#{cmd}` unless $DRYRUN
+ env = {'GIT_AUTHOR_DATE'=>date, 'GIT_COMMITTER_DATE'=>date}
+ cmd = ['git', '-C', root.to_s, 'tag', '-a', '-F', file, label.to_s, ref.to_s]
+ puts cmd.join(' ') if $DEBUG
+ system(env, *cmd) unless $DRYRUN
end
private
- #
- #
- #
+ # Run git in the project's root and return what it prints.
+ def git(*args)
+ IO.popen(['git', '-C', root.to_s, *args], :err=>File::NULL, &:read).to_s
+ end
+
+ # Details of a single commit.
def git_show(ref)
- command = 'git show ' + ref.to_s + ' --name-only --pretty=format:"' +
- '%ci' +
- GIT_FIELD_MARKER +
- '%cn' +
- GIT_FIELD_MARKER +
- '%ce' +
- GIT_FIELD_MARKER +
- '%H' +
- GIT_FIELD_MARKER +
- '%s%n%n%b' +
- GIT_FIELD_MARKER +
- '"'
-
- entry = `#{command}`
-
- date, who, email, id, msg, files = entry.split(RUBY_FIELD_MARKER)
-
- who = who + ' ' + email
- date = Time.parse(date)
- files = files.split("\n")
-
- return { :date=>date, :who=>who, :id=>id, :message=>msg, :files=>files }
+ format = ['%ci', '%cn', '%ce', '%H', '%s%n%n%b', ''].join('%x1f')
+ entry = git('show', '--name-only', "--pretty=format:#{format}", ref.to_s)
+
+ date, who, email, id, msg, files = entry.split(FIELD)
+
+ { :date => Time.parse(date),
+ :who => "#{who} #{email}",
+ :id => id,
+ :message => msg.to_s.strip,
+ :files => files.to_s.split("\n").reject{ |f| f.empty? } }
end
end
diff --git a/lib/vclog/adapters/svn.rb b/lib/vclog/adapters/svn.rb
index 2764fb3..d110af2 100644
--- a/lib/vclog/adapters/svn.rb
+++ b/lib/vclog/adapters/svn.rb
@@ -135,7 +135,7 @@ def tag(ref, label, date, message)
file = tempfile("message", message)
Dir.chdir(root) do
- cmd = %[svn copy -r #{ref} -F "#{mfile.path}" . #{tag_directory}/#{label}]
+ cmd = %[svn copy -r #{ref} -F "#{file}" . #{tag_directory}/#{label}]
puts cmd if $DEBUG
`#{cmd}` unless $DRYRUN
end
diff --git a/lib/vclog/change.rb b/lib/vclog/change.rb
index 6b83ed3..1b1b328 100644
--- a/lib/vclog/change.rb
+++ b/lib/vclog/change.rb
@@ -12,19 +12,19 @@ class Change
attr_accessor :id
# Date/time of commit.
- attr_accessor :date
+ attr_reader :date
# Committer.
- attr_accessor :author
+ attr_reader :author
# Commit message.
- attr_accessor :message
+ attr_reader :message
# List of files changed in the commit.
attr_accessor :files
# Type of change, as assigned by hueristics.
- attr_accessor :type
+ attr_reader :type
# The priority level of this change, as assigned by hueristics.
# This can be `nil`, as Heuristics will always make sure a
@@ -37,7 +37,7 @@ class Change
# ANSI color to apply. Actually this can be a list
# of any support ansi gem terms, but usually it's
# just the color term, such as `:red`.
- attr_accessor :color
+ attr_reader :color
# Setup new Change instance.
def initialize(data={})
@@ -69,11 +69,11 @@ def date=(date)
# Set the commit message.
#
def message=(msg)
- @message = msg
+ @message = msg = msg.to_s
lines = msg.lines.to_a
- @summary = lines.first.strip
- @details = lines[1..-1].join('').strip
+ @summary = lines.first.to_s.strip
+ @details = lines.drop(1).join('').strip
msg
end
diff --git a/lib/vclog/change_point.rb b/lib/vclog/change_point.rb
index 599da80..631f13f 100644
--- a/lib/vclog/change_point.rb
+++ b/lib/vclog/change_point.rb
@@ -42,7 +42,6 @@ def method_missing(s,*a,&b)
if @change.respond_to?(s)
@change.send(s,*a,&b)
else
-p caller
super(s,*a,&b)
end
end
diff --git a/lib/vclog/cli/abstract.rb b/lib/vclog/cli/abstract.rb
index 40f7be5..0746a97 100644
--- a/lib/vclog/cli/abstract.rb
+++ b/lib/vclog/cli/abstract.rb
@@ -21,8 +21,8 @@ def self.run(argv)
if $DEBUG
raise err
else
- puts err.message
- exit -1
+ $stderr.puts err.message
+ exit(-1)
end
end
diff --git a/lib/vclog/config.rb b/lib/vclog/config.rb
index d625572..72786f5 100644
--- a/lib/vclog/config.rb
+++ b/lib/vclog/config.rb
@@ -1,5 +1,4 @@
require 'vclog/heuristics'
-#require 'vclog/rc'
module VCLog
@@ -112,7 +111,11 @@ def vcs_type
# The vclog config file.
#
def file
- DEFAULT_GLOBS.find{ |g| Dir.glob(g).first }
+ FILE_GLOBS.each do |glob|
+ found = Dir.glob(File.join(root, glob)).find{ |f| File.file?(f) }
+ return found if found
+ end
+ nil
end
#
@@ -128,12 +131,15 @@ def file
#
def lookup_root
root = nil
- Dir.ascend(Dir.pwd) do |path|
- check = Dir[ROOT_GLOB].first
- if check
- root = path
+ dir = Dir.pwd
+ loop do
+ if Dir.glob(File.join(dir, ROOT_GLOB)).first
+ root = dir
break
end
+ parent = File.dirname(dir)
+ break if parent == dir
+ dir = parent
end
root || Dir.pwd
end
diff --git a/lib/vclog/core_ext.rb b/lib/vclog/core_ext.rb
index 4df7e2b..f60a056 100644
--- a/lib/vclog/core_ext.rb
+++ b/lib/vclog/core_ext.rb
@@ -1,11 +1,21 @@
+require 'ostruct'
require 'facets/string/fold'
-require 'facets/string/indent'
-require 'facets/string/tabto'
-require 'facets/string/margin'
-require 'facets/enumerable/group_by'
require 'facets/kernel/ask'
class OpenStruct
method_undef(:type) if method_defined?(:type)
end
+class String
+ # Indent the text so its first line with any content starts at column
+ # +n+, keeping the relative indentation of the lines after it. Facets
+ # had this until 4.0.
+ def tabto(n)
+ lead = self[/^([ \t]*)\S/, 1].to_s.size
+ if n >= lead
+ gsub(/^(?=.)/, ' ' * (n - lead))
+ else
+ gsub(/^[ \t]{0,#{lead - n}}/, '')
+ end
+ end unless method_defined?(:tabto)
+end
diff --git a/lib/vclog/heuristics.rb b/lib/vclog/heuristics.rb
index cfcbbd4..46aea8c 100644
--- a/lib/vclog/heuristics.rb
+++ b/lib/vclog/heuristics.rb
@@ -26,7 +26,7 @@ def self.load(file)
# Configuration script.
#
def self.eval(script, file='(eval)', line=0)
- new{ instance_eval(text, file, line) }
+ new{ instance_eval(script, file, line) }
end
#
@@ -113,7 +113,7 @@ def colors(*list)
# Set default level.
#
def level(integer=nil)
- @level = integer.to_i is integer
+ @level = integer.to_i if integer
@level
end
@@ -129,25 +129,25 @@ def default
type :test, -2, "Test/Spec Adjustments"
type :admin, -3, "Administrative Changes"
- on /\A(\w+):/ do |commit, md|
+ on(/\A(\w+):/) do |commit, md|
type = md[1].to_sym
commit.type = type
commit.message = commit.message.sub(md[0],'').strip
true
end
- on /\[(\w+)\]\s*$/ do |commit, md|
+ on(/\[(\w+)\]\s*$/) do |commit, md|
type = md[1].to_sym
commit.type = type
commit.message = commit.message.sub(md[0],'').strip
true
end
- on /updated? (README|PROFILE|PACKAGE|VERSION|MANIFEST)/ do |commit|
+ on(/updated? (README|PROFILE|PACKAGE|VERSION|MANIFEST)/) do |commit|
commit.type = :admin
end
- on /(bump|bumped|prepare) version/ do |commit|
+ on(/(bump|bumped|prepare) version/) do |commit|
commit.type = :admin
end
end
diff --git a/lib/vclog/history_file.rb b/lib/vclog/history_file.rb
index f71e006..6ca8c81 100644
--- a/lib/vclog/history_file.rb
+++ b/lib/vclog/history_file.rb
@@ -6,7 +6,7 @@ module VCLog
#
class HistoryFile
- FILE = '{HISTORY,HISTORY.*}'
+ FILE = /\Ahistory(\.\w+)?\z/i
LINE = /^[=#]/
VERS = /(\d+[._])+\d+/
@@ -20,14 +20,15 @@ class HistoryFile
# Setup new HistoryFile instance.
def initialize(source=nil)
+ source = source.to_s
if File.file?(source)
@file = source
@root = File.dirname(source)
elsif File.directory?(source)
- @file = Dir.glob(File.join(source,FILE), CASEFOLD).first
+ @file = find(source)
@root = source
else
- @file = Dir.glob(FILE).first
+ @file = find(Dir.pwd)
@root = Dir.pwd
end
raise "no history file" unless @file
@@ -35,6 +36,12 @@ def initialize(source=nil)
@tags = extract_tags
end
+ # Find the history file in a directory, whatever its case.
+ def find(dir)
+ name = Dir.children(dir).sort.find{ |f| FILE =~ f && File.file?(File.join(dir, f)) }
+ name && File.join(dir, name)
+ end
+
# Parse history file.
def extract_tags
tags = []
diff --git a/lib/vclog/metadata.rb b/lib/vclog/metadata.rb
index 6ab0c5e..d52abac 100644
--- a/lib/vclog/metadata.rb
+++ b/lib/vclog/metadata.rb
@@ -1,16 +1 @@
-module VCLog
-
- def self.metadata
- @metadata ||= (
- require 'yaml'
- YAML.load_file(File.dirname(__FILE__) + '/../vclog.yml')
- )
- end
-
- def self.const_missing(name)
- key = name.to_s.downcase
- metadata.key?(key) ? metadata[key] : super(name)
- end
-
-end
-
+require 'vclog/version'
diff --git a/lib/vclog/rc.rb b/lib/vclog/rc.rb
deleted file mode 100644
index 1fb90d1..0000000
--- a/lib/vclog/rc.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-begin
- require 'rc/api'
-
- configure 'vclog' do |config|
- VCLog.configure(&config) if config.profile?
- end
-rescue LoadError
-end
-
diff --git a/lib/vclog/repo.rb b/lib/vclog/repo.rb
index 486989f..6e41ddb 100644
--- a/lib/vclog/repo.rb
+++ b/lib/vclog/repo.rb
@@ -19,11 +19,6 @@ class Repo
#
ROOT_GLOB = '{.ruby,.map/,.git/,.hg/,_darcs/,.svn/}'
- #
- # Project's root directory.
- #
- attr :root
-
#
# Options hash.
#
@@ -178,7 +173,7 @@ def releases(changes)
# gather changes for each delta
delta.each do |tag, (started, ended)|
if started
- set = changes.select{ |c| c.date >= started && c.date < ended }
+ set = changes.select{ |c| c.date > started && c.date <= ended }
#gt_vers, gt_date = gt.name, gt.date
#lt_vers, lt_date = lt.name, lt.date
#gt_date = Time.parse(gt_date) unless Time===gt_date
@@ -188,7 +183,7 @@ def releases(changes)
#lt_vers, lt_date = lt.name, lt.date
#lt_date = Time.parse(lt_date) unless Time===lt_date
#log = changelog.before(lt_date)
- set = changes.select{ |c| c.date < ended }
+ set = changes.select{ |c| c.date <= ended }
end
rel << Release.new(tag, set)
end
@@ -229,12 +224,7 @@ def bump
def bump_part(part=nil)
raise "bad version part - #{part}" unless ['major', 'minor', 'patch', 'build', ''].include?(part.to_s)
- if tags.last
- v = tags[-1].name # TODO: ensure the latest version
- v = tags[-2].name if v == 'HEAD'
- else
- v = '0.0.0'
- end
+ v = adapter.version
v = v.split(/\W/) # TODO: preserve split chars
diff --git a/lib/vclog/report.rb b/lib/vclog/report.rb
index bb58da3..5d8ca0f 100644
--- a/lib/vclog/report.rb
+++ b/lib/vclog/report.rb
@@ -45,7 +45,7 @@ def initialize(repo, options)
# Returns a Changelog object.
#
def changelog
- changes = options.point ? repo.changes : repo.change_points
+ changes = options.point ? repo.change_points : repo.changes
ChangeLog.new(changes).above(options.level)
end
@@ -140,7 +140,7 @@ def print
when '.rb'
eval(tmpl, binding, tmpl_file)
when '.erb'
- erb = ERB.new(tmpl, nil, '<>')
+ erb = ERB.new(tmpl, :trim_mode=>'<>')
erb.result(binding)
else
raise "unrecognized template type -- #{tmpl_file}"
@@ -191,7 +191,12 @@ def rdoc
@_rdoc ||= (
gem 'rdoc' rescue nil # to ensure latest version
require 'rdoc'
- RDoc::Markup::ToHtml.new
+ # The arguments this takes have changed between RDoc versions.
+ begin
+ RDoc::Markup::ToHtml.new(RDoc::Options.new)
+ rescue ArgumentError
+ RDoc::Markup::ToHtml.new
+ end
)
end
diff --git a/lib/vclog/tag.rb b/lib/vclog/tag.rb
index 0cec049..695c39d 100644
--- a/lib/vclog/tag.rb
+++ b/lib/vclog/tag.rb
@@ -11,22 +11,22 @@ class Tag
#
# Tag name, which in this case is typically a version stamp.
#
- attr_accessor :name
+ attr_reader :name
#
# Date tag was made.
#
- attr_accessor :date
+ attr_reader :date
#
# Creator to the tag.
#
- attr_accessor :author
+ attr_reader :author
#
# Tag message.
#
- attr_accessor :message
+ attr_reader :message
#
# Last commit before Tag.
@@ -94,7 +94,7 @@ def date=(date)
# Set the tag message.
#
def message=(msg)
- @message = msg.strip
+ @message = msg.to_s.strip
end
#
@@ -128,12 +128,25 @@ def inspect
# Normal tag order is the reverse typical sorts.
#
def <=>(other)
+ return 0 if name == other.name
return -1 if name == 'HEAD'
- other.name <=> name
+ return 1 if other.name == 'HEAD'
+ a, b = version_of(name), version_of(other.name)
+ (a && b) ? (b <=> a) : (other.name <=> name)
end
private
+ #
+ # The tag's name as a version number, if it can be read as one, so
+ # that 1.10 sorts after 1.9.
+ #
+ def version_of(name)
+ Gem::Version.new(name.sub(/\A[^\d]*/, ''))
+ rescue ArgumentError
+ nil
+ end
+
#
#
#
diff --git a/lib/vclog/version.rb b/lib/vclog/version.rb
new file mode 100644
index 0000000..e55ce6c
--- /dev/null
+++ b/lib/vclog/version.rb
@@ -0,0 +1,3 @@
+module VCLog
+ VERSION = '1.10.0'
+end
diff --git a/spec/feature_commands.rb b/spec/feature_commands.rb
new file mode 100644
index 0000000..3f585f9
--- /dev/null
+++ b/spec/feature_commands.rb
@@ -0,0 +1,35 @@
+Feature "Version Commands" do
+ As "a maintainer"
+ We "want to know the current version and the next one"
+
+ Scenario "Current version" do
+ Given "a suitable Git repository"
+ When "I run `vclog-version`"
+ Then "the exit status should be 0"
+ And 'the output should be "0.10.0"'
+ end
+
+ Scenario "Bumped version" do
+ Given "a suitable Git repository"
+ When "I run `vclog-bump`"
+ Then "the exit status should be 0"
+ And 'the output should be "0.11.0"'
+ end
+
+ Scenario "Latest release note" do
+ Given "a suitable Git repository"
+ When "I run `vclog-news`"
+ Then "the exit status should be 0"
+ And 'the output should be "The second release fixes the frobnicator."'
+ end
+
+ Scenario "List of formats" do
+ Given "a suitable Git repository"
+ When "I run `vclog-formats`"
+ Then "the exit status should be 0"
+ And 'the output should include "markdown"'
+ end
+
+ include RepoCreation
+ include Shellout
+end
diff --git a/spec/feature_git_changes.rb b/spec/feature_git_changes.rb
index 1269457..90d0830 100644
--- a/spec/feature_git_changes.rb
+++ b/spec/feature_git_changes.rb
@@ -1,6 +1,3 @@
-#require_relative 'featurettes/repo_creation'
-#require_relative 'featurettes/shellout'
-
Feature "Git Change Log Support" do
As "Git users"
We "want to generate nicely formatted change logs"
@@ -9,48 +6,83 @@
Given "a suitable Git repository"
When "I run `vclog`"
Then "the exit status should be 0"
+ And 'the output should include "Add the frobnicator."'
end
Scenario "Git Changelog in RDoc" do
Given "a suitable Git repository"
When "I run `vclog -f rdoc`"
Then "the exit status should be 0"
+ And 'the output should include "Add the frobnicator."'
end
Scenario "Git Changelog in Markdown" do
Given "a suitable Git repository"
When "I run `vclog -f markdown`"
Then "the exit status should be 0"
+ And 'the output should include "Add the frobnicator."'
+ end
+
+ Scenario "Git Changelog in GNU style" do
+ Given "a suitable Git repository"
+ When "I run `vclog -f gnu`"
+ Then "the exit status should be 0"
+ And 'the output should include "Add the frobnicator."'
end
Scenario "Git Changelog in HTML" do
Given "a suitable Git repository"
When "I run `vclog -f html`"
Then "the exit status should be 0"
+ And 'the output should include "Add the frobnicator."'
end
Scenario "Git Changelog in XML" do
Given "a suitable Git repository"
When "I run `vclog -f xml`"
Then "the exit status should be 0"
+ And 'the output should include "Add the frobnicator."'
end
Scenario "Git Changelog in Atom" do
Given "a suitable Git repository"
When "I run `vclog -f atom`"
Then "the exit status should be 0"
+ And 'the output should include "Add the frobnicator."'
+ end
+
+ Scenario "Git Changelog in RSS" do
+ Given "a suitable Git repository"
+ When "I run `vclog -f rss`"
+ Then "the exit status should be 0"
+ And 'the output should include "Add the frobnicator."'
end
Scenario "Git Changelog in YAML" do
Given "a suitable Git repository"
When "I run `vclog -f yaml`"
Then "the exit status should be 0"
+ And 'the output should include "Add the frobnicator."'
end
Scenario "Git Changelog in JSON" do
Given "a suitable Git repository"
When "I run `vclog -f json`"
Then "the exit status should be 0"
+ And 'the output should include "Add the frobnicator."'
+ end
+
+ Scenario "Git Changelog leaves out changes below the level asked for" do
+ Given "a suitable Git repository"
+ When "I run `vclog -f gnu`"
+ Then 'the output should not include "Update the manual."'
+ end
+
+ Scenario "Git Changelog at a lower level" do
+ Given "a suitable Git repository"
+ When "I run `vclog -f gnu -l -5`"
+ Then 'the output should include "Update the manual."'
+ And 'the output should include "Initial commit."'
end
include RepoCreation
diff --git a/spec/feature_git_history.rb b/spec/feature_git_history.rb
index f94f37f..f8f0ce4 100644
--- a/spec/feature_git_history.rb
+++ b/spec/feature_git_history.rb
@@ -1,56 +1,84 @@
-#require_relative 'featurettes/repo_creation'
-#require_relative 'featurettes/shellout'
-
Feature "Git Release History Support" do
As "Git users"
We "want to generate nicely formatted release histories"
Scenario "Git Release History" do
Given "a suitable Git repository"
- When "I run `vclog r`"
+ When "I run `vclog -r`"
Then "the exit status should be 0"
+ And 'the output should include "Add the frobnicator."'
end
Scenario "Git Release History in RDoc" do
Given "a suitable Git repository"
- When "I run `vclog r -f rdoc`"
+ When "I run `vclog -r -f rdoc`"
Then "the exit status should be 0"
+ And 'the output should include "Add the frobnicator."'
end
Scenario "Git Release History in Markdown" do
Given "a suitable Git repository"
- When "I run `vclog rel -f markdown`"
+ When "I run `vclog -r -f markdown`"
+ Then "the exit status should be 0"
+ And 'the output should include "Add the frobnicator."'
+ end
+
+ Scenario "Git Release History in GNU style" do
+ Given "a suitable Git repository"
+ When "I run `vclog -r -f gnu`"
Then "the exit status should be 0"
+ And 'the output should include "Add the frobnicator."'
end
Scenario "Git Release History in HTML" do
Given "a suitable Git repository"
- When "I run `vclog rel -f html`"
+ When "I run `vclog -r -f html`"
Then "the exit status should be 0"
+ And 'the output should include "Add the frobnicator."'
end
Scenario "Git Release History in XML" do
Given "a suitable Git repository"
- When "I run `vclog rel -f xml`"
+ When "I run `vclog -r -f xml`"
Then "the exit status should be 0"
+ And 'the output should include "Add the frobnicator."'
end
Scenario "Git Release History in Atom" do
Given "a suitable Git repository"
- When "I run `vclog rel -f atom`"
+ When "I run `vclog -r -f atom`"
+ Then "the exit status should be 0"
+ And 'the output should include "Add the frobnicator."'
+ end
+
+ Scenario "Git Release History in RSS" do
+ Given "a suitable Git repository"
+ When "I run `vclog -r -f rss`"
Then "the exit status should be 0"
+ And 'the output should include "Add the frobnicator."'
end
Scenario "Git Release History in YAML" do
Given "a suitable Git repository"
- When "I run `vclog rel -f yaml`"
+ When "I run `vclog -r -f yaml`"
Then "the exit status should be 0"
+ And 'the output should include "Add the frobnicator."'
end
Scenario "Git Release History in JSON" do
Given "a suitable Git repository"
- When "I run `vclog rel -f json`"
+ When "I run `vclog -r -f json`"
Then "the exit status should be 0"
+ And 'the output should include "Add the frobnicator."'
+ end
+
+ Scenario "Git Release History names each release" do
+ Given "a suitable Git repository"
+ When "I run `vclog -r -f markdown`"
+ Then 'the output should include "## 0.1.0 / 2020-01-02"'
+ And 'the output should include "## 0.2.0 / 2020-01-04"'
+ And 'the output should include "## 0.10.0 / 2020-01-07"'
+ And 'the output should include "The first release."'
end
include RepoCreation
diff --git a/spec/feature_hg_changes.rb b/spec/feature_hg_changes.rb
deleted file mode 100644
index 90b49a2..0000000
--- a/spec/feature_hg_changes.rb
+++ /dev/null
@@ -1,58 +0,0 @@
-#require_relative 'featurettes/repo_creation'
-#require_relative 'featurettes/shellout'
-
-Feature "Mercurial Support" do
- As "Mercurial users"
- We "want to generate a nicely formatted Changelog"
-
- Scenario "Mercurial Changelog" do
- Given "a suitable Mercurial repository"
- When "I run `vclog`"
- Then "the exit status should be 0"
- end
-
- Scenario "Mercurial Changelog in RDoc" do
- Given "a suitable Mercurial repository"
- When "I run `vclog -f rdoc`"
- Then "the exit status should be 0"
- end
-
- Scenario "Mercurial Changelog in Markdown" do
- Given "a suitable Mercurial repository"
- When "I run `vclog -f markdown`"
- Then "the exit status should be 0"
- end
-
- Scenario "Mercurial Changelog in HTML" do
- Given "a suitable Mercurial repository"
- When "I run `vclog -f html`"
- Then "the exit status should be 0"
- end
-
- Scenario "Mercurial Changelog in XML" do
- Given "a suitable Mercurial repository"
- When "I run `vclog -f xml`"
- Then "the exit status should be 0"
- end
-
- Scenario "Mercurial Changelog in Atom" do
- Given "a suitable Mercurial repository"
- When "I run `vclog -f atom`"
- Then "the exit status should be 0"
- end
-
- Scenario "Mercurial Changelog in YAML" do
- Given "a suitable Mercurial repository"
- When "I run `vclog -f yaml`"
- Then "the exit status should be 0"
- end
-
- Scenario "Mercurial Changelog in JSON" do
- Given "a suitable Mercurial repository"
- When "I run `vclog -f json`"
- Then "the exit status should be 0"
- end
-
- include RepoCreation
- include Shellout
-end
diff --git a/spec/feature_hg_history.rb b/spec/feature_hg_history.rb
deleted file mode 100644
index 571358c..0000000
--- a/spec/feature_hg_history.rb
+++ /dev/null
@@ -1,58 +0,0 @@
-#require_relative 'featurettes/repo_creation'
-#require_relative 'featurettes/shellout'
-
-Feature "Mercurial Release History Support" do
- As "Mercurial users"
- We "want to generate nicely formatted Release Histories"
-
- Scenario "Mercurial Release History" do
- Given "a suitable Mercurial repository"
- When "I run `vclog rel`"
- Then "the exit status should be 0"
- end
-
- Scenario "Mercurial Release History in RDoc" do
- Given "a suitable Mercurial repository"
- When "I run `vclog rel -f rdoc`"
- Then "the exit status should be 0"
- end
-
- Scenario "Mercurial Release History in Markdown" do
- Given "a suitable Mercurial repository"
- When "I run `vclog rel -f markdown`"
- Then "the exit status should be 0"
- end
-
- Scenario "Mercurial Release History in HTML" do
- Given "a suitable Mercurial repository"
- When "I run `vclog rel -f html`"
- Then "the exit status should be 0"
- end
-
- Scenario "Mercurial Release History in XML" do
- Given "a suitable Mercurial repository"
- When "I run `vclog rel -f xml`"
- Then "the exit status should be 0"
- end
-
- Scenario "Mercurial Release History in Atom" do
- Given "a suitable Mercurial repository"
- When "I run `vclog rel -f atom`"
- Then "the exit status should be 0"
- end
-
- Scenario "Mercurial Release History in YAML" do
- Given "a suitable Mercurial repository"
- When "I run `vclog rel -f yaml`"
- Then "the exit status should be 0"
- end
-
- Scenario "Mercurial Release History in JSON" do
- Given "a suitable Mercurial repository"
- When "I run `vclog rel -f json`"
- Then "the exit status should be 0"
- end
-
- include RepoCreation
- include Shellout
-end
diff --git a/spec/featurettes/repo_creation.rb b/spec/featurettes/repo_creation.rb
index 59edf6a..3ef17a3 100644
--- a/spec/featurettes/repo_creation.rb
+++ b/spec/featurettes/repo_creation.rb
@@ -1,64 +1,8 @@
module RepoCreation
- include Lime::Featurette
+ include Spectrum::Featurette
Given 'a suitable Git repository' do
- url = "git://github.com/rubyworks/vclog.git"
- name = "vclog"
- type = "git"
- marker = ".git"
- clone = "git clone #{url} #{name}"
-
- setup_repo(name, type, marker, clone)
- end
-
- Given 'a suitable Mercurial repository' do
- url = "http://bitbucket.org/birkenfeld/sphinx"
- name = "sphinx"
- type = "hg"
- marker = ".hg"
- clone = "hg clone #{url} #{name}"
-
- setup_repo(name, type, marker, clone)
- end
-
- Given 'a suitable Subversion repository' do
- url = "svn://rubyforge.org/var/svn/rubygems"
- name = "rubygems"
- type = "svn"
- marker = ".svn"
- clone = "svn checkout #{url} #{name}"
-
- setup_repo(name, type, marker, clone)
- end
-
- # TODO: test darcs repo
- Given 'a suitable Darcs repository' do
- url =
- name =
- type = "darcs"
- marker = "_darcs"
- clone = ""
- end
-
- #
- # Checkout reporsitory if need be and copy to working location.
- #
- def setup_repo(name, type, marker, clone_command)
- dir = File.expand_path("tmp/hold/#{type}")
- dst = File.expand_path("tmp/repo/#{type}")
-
- unless File.exist?("#{dir}/#{name}/#{marker}")
- $stderr.puts(" #{clone_command}")
- `mkdir -p #{dir}` unless File.directory?(dir)
- `cd #{dir}; #{clone_command}`
- end
-
- unless File.directory?("#{dst}/#{name}")
- `mkdir -p #{dst}`
- `cp -r #{dir}/#{name} #{dst}/#{name}`
- end
-
- @working_directory = "#{dst}/#{name}"
+ @working_directory = git_fixture
end
end
diff --git a/spec/featurettes/shellout.rb b/spec/featurettes/shellout.rb
index 8cd8a79..2e16e84 100644
--- a/spec/featurettes/shellout.rb
+++ b/spec/featurettes/shellout.rb
@@ -1,16 +1,24 @@
-require 'open3'
-
module Shellout
- include Lime::Featurette
+ include Spectrum::Featurette
+
+ When 'I run `(.*?)`' do |cmd|
+ @stdout, @stderr, @status = run_command(cmd, @working_directory)
+ end
+
+ Then 'the exit status should be (\d+)' do |status|
+ @status.assert == status.to_i
+ end
+
+ Then 'the output should include "(.*?)"' do |text|
+ @stdout.assert.include?(text)
+ end
- When 'I run `(((.*?)))`' do |cmd|
- Dir.chdir(@working_directory) do
- @stdout, @stderr, @status = Open3.capture3(cmd)
- end
+ Then 'the output should not include "(.*?)"' do |text|
+ @stdout.refute.include?(text)
end
- Then 'the exit status should be (((\d+)))' do |status|
- @status = status.to_i
+ Then 'the output should be "(.*?)"' do |text|
+ @stdout.strip.assert == text
end
end
diff --git a/test/case_git.rb b/test/case_git.rb
new file mode 100644
index 0000000..d351a8b
--- /dev/null
+++ b/test/case_git.rb
@@ -0,0 +1,70 @@
+testcase VCLog::Adapters::Git do
+
+ setup do
+ @repo = VCLog::Repo.new(git_fixture, {})
+ end
+
+ test "every commit is a change, newest first" do
+ @repo.changes.size.assert == 6
+ @repo.changes.first.message.assert == "Add a second frobnicator."
+ @repo.changes.last.message.assert == "Initial commit."
+ end
+
+ test "a change has an author, a date, an id and its files" do
+ change = @repo.changes.find{ |c| c.message == "Add the frobnicator." }
+ change.author.assert == "Tester"
+ change.date.utc.strftime('%Y-%m-%d').assert == "2020-01-02"
+ change.id.assert =~ /\A[0-9a-f]{40}\z/
+ change.files.assert == ["frob.rb"]
+ end
+
+ test "a commit with no files is still a change" do
+ change = @repo.changes.find{ |c| c.message == "Update the manual." }
+ change.files.assert == []
+ end
+
+ test "heuristics give a change its type and take the mark off its message" do
+ @repo.changes.map{ |c| c.type }.assert == [:default, :default, :doc, :bug, :major, :admin]
+ end
+
+ test "the rest of a commit message is its details" do
+ change = @repo.changes.find{ |c| c.summary == "Polish the frobnicator." }
+ change.details.assert == "* Sand it.\n* Paint it."
+ end
+
+ test "an annotated tag has its own message, author and date" do
+ tag = @repo.tags.find{ |t| t.name == '0.1.0' }
+ tag.message.assert == "The first release."
+ tag.author.assert == "Tester "
+ tag.date.utc.strftime('%Y-%m-%d').assert == "2020-01-02"
+ tag.commit.message.assert == "Add the frobnicator. [major]"
+ end
+
+ test "a lightweight tag takes them from its commit" do
+ tag = @repo.tags.find{ |t| t.name == '0.2.0' }
+ tag.message.assert == "Update the manual. [doc]"
+ tag.date.utc.strftime('%Y-%m-%d').assert == "2020-01-04"
+ end
+
+ test "the current version is the highest tag, not the last by name" do
+ @repo.version.assert == "0.10.0"
+ end
+
+ test "a release holds the changes up to and including its tagged commit" do
+ releases = @repo.releases(@repo.changes)
+ listing = releases.map{ |r| [r.tag.name, r.changes.map{ |c| c.summary }] }
+ listing.assert == [
+ ['HEAD', ["Add a second frobnicator."]],
+ ['0.10.0', ["Polish the frobnicator."]],
+ ['0.2.0', ["Update the manual.", "Fix the frobnicator."]],
+ ['0.1.0', ["Add the frobnicator.", "Initial commit."]]
+ ]
+ end
+
+ test "bump parts" do
+ @repo.bump_part('major').assert == "1.0.0"
+ @repo.bump_part('minor').assert == "0.11.0"
+ @repo.bump_part('patch').assert == "0.10.1"
+ end
+
+end
diff --git a/test/case_heuristics.rb b/test/case_heuristics.rb
new file mode 100644
index 0000000..7a2b553
--- /dev/null
+++ b/test/case_heuristics.rb
@@ -0,0 +1,53 @@
+testcase VCLog::Heuristics do
+
+ def change(message)
+ VCLog::Change.new(:id=>'1', :date=>'2020-01-01', :who=>'Tester', :msg=>message)
+ end
+
+ test "a trailing mark in brackets sets the type" do
+ c = change("Fix it. [bug]")
+ VCLog::Heuristics.new.apply(c)
+ c.type.assert == :bug
+ c.label.assert == "Bug Fixes"
+ c.level.assert == 1
+ c.message.assert == "Fix it."
+ end
+
+ test "a leading word and colon sets the type" do
+ c = change("doc: Explain it.")
+ VCLog::Heuristics.new.apply(c)
+ c.type.assert == :doc
+ c.message.assert == "Explain it."
+ end
+
+ test "an unmarked change is nominal" do
+ c = change("Do something.")
+ VCLog::Heuristics.new.apply(c)
+ c.type.assert == :default
+ c.level.assert == 0
+ end
+
+ test "rules can be given as a script" do
+ h = VCLog::Heuristics.eval(<<-END)
+ type :chore, -4, "Chores"
+ on(/tidy/) do |commit|
+ commit.type = :chore
+ end
+ END
+ c = change("tidy up")
+ h.apply(c)
+ c.label.assert == "Chores"
+ c.level.assert == -4
+ end
+
+ test "rules are loaded from a project's config file" do
+ Dir.mktmpdir do |dir|
+ Dir.mkdir(File.join(dir, 'etc'))
+ File.write(File.join(dir, 'etc', 'vclog.rb'), %[type :chore, -4, "Chores"\n])
+ config = VCLog::Config.new(:root=>dir)
+ config.file.assert == File.join(dir, 'etc', 'vclog.rb')
+ config.heuristics.types[:chore].label.assert == "Chores"
+ end
+ end
+
+end
diff --git a/test/case_history_file.rb b/test/case_history_file.rb
new file mode 100644
index 0000000..61eedef
--- /dev/null
+++ b/test/case_history_file.rb
@@ -0,0 +1,27 @@
+testcase VCLog::HistoryFile do
+
+ test "finds the history file whatever its case" do
+ Dir.mktmpdir do |dir|
+ File.write(File.join(dir, 'History.md'), "## 1.0.0 / 2020-02-02\n\nA note.\n")
+ VCLog::HistoryFile.new(dir).tags.map{ |t| t.name }.assert == ['1.0.0']
+ end
+ end
+
+ test "raises when there is none" do
+ Dir.mktmpdir do |dir|
+ RuntimeError.assert.raised?{ VCLog::HistoryFile.new(dir) }
+ end
+ end
+
+ test "each release heading becomes a tag" do
+ tags = VCLog::HistoryFile.new(git_fixture).tags
+ tags.map{ |t| t.name }.assert == ['0.2.0', '0.1.0']
+ tags.first.date.strftime('%Y-%m-%d').assert == '2020-01-04'
+ tags.first.message.assert == "The second release fixes the frobnicator."
+ end
+
+ test "news is the latest release note" do
+ VCLog::HistoryFile.new(git_fixture).news.assert == "The second release fixes the frobnicator."
+ end
+
+end
diff --git a/test/case_metadata.rb b/test/case_metadata.rb
index ecc1988..41e5712 100644
--- a/test/case_metadata.rb
+++ b/test/case_metadata.rb
@@ -1,10 +1,7 @@
-require 'vclog/metadata'
-
testcase "VCLog" do
test "VERSION is set" do
- ::VCLog::VERSION.assert == File.read('index/version').strip
+ ::VCLog::VERSION.assert =~ /\A\d+\.\d+\.\d+\z/
end
end
-
diff --git a/test/case_string.rb b/test/case_string.rb
new file mode 100644
index 0000000..d5a13a7
--- /dev/null
+++ b/test/case_string.rb
@@ -0,0 +1,11 @@
+testcase String do
+
+ test "tabto indents to a column" do
+ "a\n b".tabto(4).assert == " a\n b"
+ end
+
+ test "tabto can reduce the indentation" do
+ " a\n b".tabto(2).assert == " a\n b"
+ end
+
+end
diff --git a/test/case_tag.rb b/test/case_tag.rb
new file mode 100644
index 0000000..1d2f149
--- /dev/null
+++ b/test/case_tag.rb
@@ -0,0 +1,32 @@
+testcase VCLog::Tag do
+
+ def tag(name)
+ VCLog::Tag.new(:name=>name, :date=>'2020-01-01', :who=>'Tester', :msg=>'')
+ end
+
+ test "tags sort newest version first" do
+ names = %w[0.2.0 0.10.0 0.1.0 1.0.0].map{ |n| tag(n) }.sort.map{ |t| t.name }
+ names.assert == %w[1.0.0 0.10.0 0.2.0 0.1.0]
+ end
+
+ test "a v prefix doesn't matter" do
+ names = %w[v0.2.0 v0.10.0].map{ |n| tag(n) }.sort.map{ |t| t.name }
+ names.assert == %w[v0.10.0 v0.2.0]
+ end
+
+ test "HEAD sorts before any version" do
+ names = [tag('9.0.0'), tag('HEAD')].sort.map{ |t| t.name }
+ names.assert == %w[HEAD 9.0.0]
+ end
+
+end
+
+testcase VCLog::Change do
+
+ test "a change with an empty message has an empty summary" do
+ change = VCLog::Change.new(:id=>'1', :date=>'2020-01-01', :who=>'Tester', :msg=>'')
+ change.summary.assert == ''
+ change.details.assert == ''
+ end
+
+end
diff --git a/test/helper.rb b/test/helper.rb
new file mode 100644
index 0000000..9543a06
--- /dev/null
+++ b/test/helper.rb
@@ -0,0 +1,101 @@
+$LOAD_PATH.unshift File.expand_path('../lib', __dir__)
+
+require 'assay/ae'
+require 'open3'
+require 'tmpdir'
+require 'fileutils'
+require 'rbconfig'
+require 'vclog'
+
+module Spectrum::World
+
+ PROJECT = File.expand_path('..', __dir__)
+
+ # A small Git repository with a known history, built once per run.
+ #
+ # 2020-01-01 Initial commit. [admin]
+ # 2020-01-02 Add the frobnicator. [major] <- 0.1.0 (annotated)
+ # 2020-01-03 bug: Fix the frobnicator.
+ # 2020-01-04 Update the manual. [doc] <- 0.2.0 (lightweight), no files
+ # ...
+ # 2020-01-07 Polish the frobnicator. <- 0.10.0 (annotated)
+ # 2020-01-08 Add a second frobnicator.
+ #
+ def git_fixture
+ $vclog_git_fixture ||= build_git_fixture
+ end
+
+ # Run one of the project's commands in a directory, as a user would.
+ # Returns standard output, standard error and the exit status.
+ def run_command(line, dir)
+ name, *args = line.split(' ')
+ out, err, status = Open3.capture3(
+ fixture_env, RbConfig.ruby, "-I#{PROJECT}/lib", "#{PROJECT}/bin/#{name}", *args, :chdir=>dir
+ )
+ return out, err, status.exitstatus
+ end
+
+private
+
+ def fixture_env
+ { 'GIT_CONFIG_GLOBAL' => File::NULL, 'GIT_CONFIG_SYSTEM' => File::NULL, 'RUBYOPT' => nil }
+ end
+
+ def build_git_fixture
+ dir = Dir.mktmpdir('vclog-git-')
+ at_exit{ FileUtils.remove_entry(dir) if File.directory?(dir) }
+
+ git = lambda do |date, *args|
+ env = fixture_env.merge('GIT_AUTHOR_DATE'=>"#{date} 12:00:00 +0000", 'GIT_COMMITTER_DATE'=>"#{date} 12:00:00 +0000")
+ out, status = Open3.capture2e(env, 'git', '-C', dir, *args)
+ raise "git #{args.join(' ')} failed:\n#{out}" unless status.success?
+ end
+
+ commit = lambda do |date, message, file=nil|
+ if file
+ File.write(File.join(dir, file), "#{message}\n", :mode=>'a')
+ git.call(date, 'add', file)
+ end
+ git.call(date, 'commit', '-q', '--allow-empty', '-m', message)
+ end
+
+ git.call('2020-01-01', 'init', '-q', '-b', 'master')
+ git.call('2020-01-01', 'config', 'user.name', 'Tester')
+ git.call('2020-01-01', 'config', 'user.email', 'tester@example.com')
+ git.call('2020-01-01', 'config', 'commit.gpgsign', 'false')
+ git.call('2020-01-01', 'config', 'tag.gpgsign', 'false')
+
+ File.write(File.join(dir, 'HISTORY.md'), <<-END.gsub(/^ {6}/, ''))
+ # RELEASE HISTORY
+
+ ## 0.2.0 / 2020-01-04
+
+ The second release fixes the frobnicator.
+
+ Changes:
+
+ * Fix the frobnicator.
+
+ ## 0.1.0 / 2020-01-02
+
+ The first release.
+
+ Changes:
+
+ * Add the frobnicator.
+ END
+
+ commit.call('2020-01-01', 'Initial commit. [admin]', 'HISTORY.md')
+ commit.call('2020-01-02', 'Add the frobnicator. [major]', 'frob.rb')
+ git.call('2020-01-02', 'tag', '-a', '-m', 'The first release.', '0.1.0')
+ commit.call('2020-01-03', 'bug: Fix the frobnicator.', 'frob.rb')
+ commit.call('2020-01-04', 'Update the manual. [doc]')
+ git.call('2020-01-04', 'tag', '0.2.0')
+ commit.call('2020-01-07', "Polish the frobnicator.\n\n* Sand it.\n* Paint it.", 'frob.rb')
+ git.call('2020-01-07', 'tag', '-a', '-m', 'Add a coat of paint.', '0.10.0')
+ commit.call('2020-01-08', 'Add a second frobnicator.', 'frob2.rb')
+
+ dir
+ end
+
+end
diff --git a/vclog.gemspec b/vclog.gemspec
new file mode 100644
index 0000000..6fc5f5f
--- /dev/null
+++ b/vclog.gemspec
@@ -0,0 +1,44 @@
+require_relative 'lib/vclog/version'
+
+Gem::Specification.new do |s|
+ s.name = 'vclog'
+ s.version = VCLog::VERSION
+ s.summary = 'Cross-VCS/SCM ChangeLog Generator'
+ s.description = 'VCLog is a versatile cross-VCS/SCM changelog and release history generator. ' \
+ 'It supports Git, Mercurial and Subversion, and a variety of output formats.'
+
+ s.authors = ['Trans']
+ s.email = ['transfire@gmail.com']
+ s.homepage = 'https://github.com/rubyworks/vclog'
+ s.license = 'BSD-2-Clause'
+
+ s.metadata = {
+ 'homepage_uri' => s.homepage,
+ 'source_code_uri' => 'https://github.com/rubyworks/vclog',
+ 'bug_tracker_uri' => 'https://github.com/rubyworks/vclog/issues',
+ 'changelog_uri' => 'https://github.com/rubyworks/vclog/blob/master/History.md',
+ 'documentation_uri' => 'https://rubydoc.info/gems/vclog'
+ }
+
+ s.required_ruby_version = '>= 2.7'
+
+ s.files = Dir[
+ 'lib/**/*', 'bin/*', 'man/**/*',
+ '.yardopts', 'README.md', 'History.md', 'License.txt'
+ ].select{ |f| File.file?(f) }
+ s.bindir = 'bin'
+ s.executables = Dir['bin/*'].map{ |f| File.basename(f) }
+ s.require_paths = ['lib']
+ s.extra_rdoc_files = ['README.md', 'History.md', 'License.txt']
+
+ s.add_dependency 'ansi', '>= 1.5'
+ s.add_dependency 'facets', '>= 2.4'
+ s.add_dependency 'json'
+ s.add_dependency 'ostruct'
+ s.add_dependency 'rdoc'
+ s.add_dependency 'xml-simple'
+
+ s.add_development_dependency 'rake', '>= 13'
+ s.add_development_dependency 'spectrum', '>= 0.2'
+ s.add_development_dependency 'assay', '>= 0.5'
+end
diff --git a/work/deprecated/config-vclog.rb b/work/deprecated/config-vclog.rb
deleted file mode 100644
index 25eac75..0000000
--- a/work/deprecated/config-vclog.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/usr/bin/env ruby
-
-type :major, 2, "Major Enhancements"
-type :minor, 1, "Minor Enhancements"
-type :bug, 0, "Bug Fixes"
-type :default, -1, "Nominal Changes"
-type :doc, -2, "Documentation Changes"
-type :test, -2, "Test/Spec Adjustments"
-type :admin, -3, "Administrative Changes"
-
-on /^(\w+):/ do |commit, md|
- type = md[1].to_sym
- commit.type = type
- commit.message = commit.message.sub(md[0],'').strip
-end
-
-on /\[(\w+)\]\s*$/ do |commit, md|
- type = md[1].to_sym
- commit.type = type
- commit.message = commit.message.sub(md[0],'').strip
-end
-
-on /updated? (README|PROFILE|PACKAGE|VERSION|MANIFEST)/ do |commit|
- commit.type = :admin
-end
-
-on /(bump|bumped|prepare) version/ do |commit|
- commit.type = :admin
-end
-
-colors :blue, :blue, :cyan, :green, :yellow, :red, [:red, :bold]
-
diff --git a/work/deprecated/features/git.feature b/work/deprecated/features/git.feature
deleted file mode 100644
index d2a1f7c..0000000
--- a/work/deprecated/features/git.feature
+++ /dev/null
@@ -1,86 +0,0 @@
-Feature: Git Support
- As a Git user
- I want to generate a nicely formatted Changelog
- And I want to generate a nicely formatted Release History
-
- Scenario: Git Changelog
- Given a suitable Git repository
- When I run `vclog`
- Then the exit status should be 0
-
- Scenario: Git Changelog in RDoc
- Given a suitable Git repository
- When I run `vclog -f rdoc`
- Then the exit status should be 0
-
- Scenario: Git Changelog in Markdown
- Given a suitable Git repository
- When I run `vclog -f markdown`
- Then the exit status should be 0
-
- Scenario: Git Changelog in HTML
- Given a suitable Git repository
- When I run `vclog -f html`
- Then the exit status should be 0
-
- Scenario: Git Changelog in XML
- Given a suitable Git repository
- When I run `vclog -f xml`
- Then the exit status should be 0
-
- Scenario: Git Changelog in Atom
- Given a suitable Git repository
- When I run `vclog -f atom`
- Then the exit status should be 0
-
- Scenario: Git Changelog in YAML
- Given a suitable Git repository
- When I run `vclog -f yaml`
- Then the exit status should be 0
-
- Scenario: Git Changelog in JSON
- Given a suitable Git repository
- When I run `vclog -f json`
- Then the exit status should be 0
-
-
- Scenario: Git Release History
- Given a suitable Git repository
- When I run `vclog r`
- Then the exit status should be 0
-
- Scenario: Git Release History in RDoc
- Given a suitable Git repository
- When I run `vclog r -f rdoc`
- Then the exit status should be 0
-
- Scenario: Git Release History in Markdown
- Given a suitable Git repository
- When I run `vclog rel -f markdown`
- Then the exit status should be 0
-
- Scenario: Git Release History in HTML
- Given a suitable Git repository
- When I run `vclog rel -f html`
- Then the exit status should be 0
-
- Scenario: Git Release History in XML
- Given a suitable Git repository
- When I run `vclog rel -f xml`
- Then the exit status should be 0
-
- Scenario: Git Release History in Atom
- Given a suitable Git repository
- When I run `vclog rel -f atom`
- Then the exit status should be 0
-
- Scenario: Git Release History in YAML
- Given a suitable Git repository
- When I run `vclog rel -f yaml`
- Then the exit status should be 0
-
- Scenario: Git Release History in JSON
- Given a suitable Git repository
- When I run `vclog rel -f json`
- Then the exit status should be 0
-
diff --git a/work/deprecated/features/hg.feature b/work/deprecated/features/hg.feature
deleted file mode 100644
index c11f828..0000000
--- a/work/deprecated/features/hg.feature
+++ /dev/null
@@ -1,86 +0,0 @@
-Feature: Mercurial Support
- As a Mercurial user
- I want to generate a nicely formatted Changelog
- And I want to generate a nicely formatted Release History
-
- Scenario: Mercurial Changelog
- Given a suitable Mercurial repository
- When I run `vclog`
- Then the exit status should be 0
-
- Scenario: Mercurial Changelog in RDoc
- Given a suitable Mercurial repository
- When I run `vclog -f rdoc`
- Then the exit status should be 0
-
- Scenario: Mercurial Changelog in Markdown
- Given a suitable Mercurial repository
- When I run `vclog -f markdown`
- Then the exit status should be 0
-
- Scenario: Mercurial Changelog in HTML
- Given a suitable Mercurial repository
- When I run `vclog -f html`
- Then the exit status should be 0
-
- Scenario: Mercurial Changelog in XML
- Given a suitable Mercurial repository
- When I run `vclog -f xml`
- Then the exit status should be 0
-
- Scenario: Mercurial Changelog in Atom
- Given a suitable Mercurial repository
- When I run `vclog -f atom`
- Then the exit status should be 0
-
- Scenario: Mercurial Changelog in YAML
- Given a suitable Mercurial repository
- When I run `vclog -f yaml`
- Then the exit status should be 0
-
- Scenario: Mercurial Changelog in JSON
- Given a suitable Mercurial repository
- When I run `vclog -f json`
- Then the exit status should be 0
-
-
- Scenario: Mercurial Release History
- Given a suitable Mercurial repository
- When I run `vclog rel`
- Then the exit status should be 0
-
- Scenario: Mercurial Release History in RDoc
- Given a suitable Mercurial repository
- When I run `vclog rel -f rdoc`
- Then the exit status should be 0
-
- Scenario: Mercurial Release History in Markdown
- Given a suitable Mercurial repository
- When I run `vclog rel -f markdown`
- Then the exit status should be 0
-
- Scenario: Mercurial Release History in HTML
- Given a suitable Mercurial repository
- When I run `vclog rel -f html`
- Then the exit status should be 0
-
- Scenario: Mercurial Release History in XML
- Given a suitable Mercurial repository
- When I run `vclog rel -f xml`
- Then the exit status should be 0
-
- Scenario: Mercurial Release History in Atom
- Given a suitable Mercurial repository
- When I run `vclog rel -f atom`
- Then the exit status should be 0
-
- Scenario: Mercurial Release History in YAML
- Given a suitable Mercurial repository
- When I run `vclog rel -f yaml`
- Then the exit status should be 0
-
- Scenario: Mercurial Release History in JSON
- Given a suitable Mercurial repository
- When I run `vclog rel -f json`
- Then the exit status should be 0
-
diff --git a/work/deprecated/features/step_definitions/history_steps.rb b/work/deprecated/features/step_definitions/history_steps.rb
deleted file mode 100644
index e125ce9..0000000
--- a/work/deprecated/features/step_definitions/history_steps.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-Given /^a SVN repository/ do
- @directory = File.dirname(__FILE__) + '/../../test/fixtures/tzinfo'
- @tag_numbers = Dir["@directory/tags/*"].map{ |d| File.basename(d) }
-end
-
-# For git we will have to use the VCLog project itself, I guess.
-Given /^a Git repository/ do
- @directory = File.dirname(__FILE__) + '/../..' #/fixtures/git-repo'
- tags1 = `cd #{@directory}; git tag -l "[0-9]*"`
- tags2 = `cd #{@directory}; git tag -l "v[0-9]*"`
- @tag_numbers = tags1.split("\n") + tags2.split("\n")
-end
-
-When /I generate a History/ do
- @system = VCLog::VCS.factory(@directory)
- @history = VCLog::History.new(@system)
-end
-
-Then /it should include all tags/ do
- tags = @history.tags.map{ |t| t.name }
- tags.sort.assert == @tag_numbers.sort
-end
-
-And /^the list of releases should be in order from newest to oldest/ do
- rels_names = @history.releases.map{ |r| r.tag.name }
- rels_names.shift # remove imaginary current tag
- rels_names.assert == @tag_numbers.sort.reverse
-end
-
diff --git a/work/deprecated/features/step_definitions/repo_steps.rb b/work/deprecated/features/step_definitions/repo_steps.rb
deleted file mode 100644
index cf28d1e..0000000
--- a/work/deprecated/features/step_definitions/repo_steps.rb
+++ /dev/null
@@ -1,72 +0,0 @@
-Given /a suitable Subversion repository/ do
- url = "svn://rubyforge.org/var/svn/rubygems"
- name = "rubygems"
- type = "svn"
- marker = ".svn"
- clone = "svn checkout #{url} #{name}"
-
- setup_repo(name, type, marker, clone)
-
- #dir = File.expand_path("tmp/hold/#{type}")
- #unless File.exist?("#{dir}/#{name}/.svn")
- # `mkdir -p #{dir}; cd #{dir}; svn checkout #{url} #{name}`
- #end
- #create_dir(type)
- #cd(type)
- #run "cp -r #{dir} #{name}"
- #cd(name)
-end
-
-Given /a suitable Git repository/ do
- url = "git://github.com/rubyworks/vclog.git"
- name = "vclog"
- type = "git"
- marker = ".git"
- clone = "git clone #{url} #{name}"
-
- setup_repo(name, type, marker, clone)
-
- #create_dir('git')
- #cd('git')
- #unless File.exist?("#{name}/.git")
- # cmd = "git clone #{url} #{name}"
- # run cmd
- #end
- #cd(name)
-end
-
-Given /a suitable Mercurial repository/ do
- url = "http://bitbucket.org/birkenfeld/sphinx"
- name = "sphinx"
- type = "hg"
- marker = ".hg"
- clone = "hg clone #{url} #{name}"
-
- setup_repo(name, type, marker, clone)
-
- #create_dir('hg')
- #cd('hg')
- #unless File.exist?("#{name}/.hg")
- # cmd = "hg clone #{url} #{name}"
- # run cmd
- #end
- #cd(name)
-end
-
-# TODO
-Given /a suitable Darcs repository/ do
- url =
- name =
- type = "darcs"
- marker = "_darcs"
- clone = ""
-
- #create_dir('darcs')
- #cd('darcs')
- #unless File.exist?("#{name}/_darcs")
- # cmd = "darcs clone "
- # #run cmd
- #end
- #cd(name)
-end
-
diff --git a/work/deprecated/features/support/ae.rb b/work/deprecated/features/support/ae.rb
deleted file mode 100644
index 84ae3d2..0000000
--- a/work/deprecated/features/support/ae.rb
+++ /dev/null
@@ -1 +0,0 @@
-require 'ae'
diff --git a/work/deprecated/features/support/aruba.rb b/work/deprecated/features/support/aruba.rb
deleted file mode 100644
index efb84b0..0000000
--- a/work/deprecated/features/support/aruba.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-require 'aruba/cucumber'
-
-Before do
- @aruba_timeout_seconds = 20
-end
diff --git a/work/deprecated/features/support/loadpath.rb b/work/deprecated/features/support/loadpath.rb
deleted file mode 100644
index 1838701..0000000
--- a/work/deprecated/features/support/loadpath.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-$LOAD_PATH.unshift( File.dirname(__FILE__) + '/../../lib' )
-require 'vclog'
diff --git a/work/deprecated/features/support/repo.rb b/work/deprecated/features/support/repo.rb
deleted file mode 100644
index c9e5c85..0000000
--- a/work/deprecated/features/support/repo.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-def setup_repo(name, type, marker, clone_command)
- dir = File.expand_path("tmp/hold/#{type}")
- dst = File.expand_path("tmp/aruba")
-
- unless File.exist?("#{dir}/#{name}/#{marker}")
- $stderr.puts(" #{clone_command}")
- `mkdir -p #{dir}` unless File.directory?(dir)
- `cd #{dir}; #{clone_command}`
- end
-
- #unless File.exist?("tmp/aruba/#{type}/#{name}")
- `mkdir -p #{dst}`
- `cp -r #{dir} #{dst}/#{type}/`
- #end
-
- cd("#{type}/#{name}")
-end
-
diff --git a/work/deprecated/features/svn.feature b/work/deprecated/features/svn.feature
deleted file mode 100644
index 330a71e..0000000
--- a/work/deprecated/features/svn.feature
+++ /dev/null
@@ -1,86 +0,0 @@
-Feature: Subversion Support
- As a Subversion user
- I want to generate a nicely formatted Changelog
- And I want to generate a nicely formatted Release History
-
- Scenario: Subversion Changelog
- Given a suitable Subversion repository
- When I run `vclog`
- Then the exit status should be 0
-
- Scenario: Subversion Changelog in RDoc
- Given a suitable Subversion repository
- When I run `vclog -f rdoc`
- Then the exit status should be 0
-
- Scenario: Subversion Changelog in Markdown
- Given a suitable Subversion repository
- When I run `vclog -f markdown`
- Then the exit status should be 0
-
- Scenario: Subversion Changelog in HTML
- Given a suitable Subversion repository
- When I run `vclog -f html`
- Then the exit status should be 0
-
- Scenario: Subversion Changelog in XML
- Given a suitable Subversion repository
- When I run `vclog -f xml`
- Then the exit status should be 0
-
- Scenario: Subversion Changelog in Atom
- Given a suitable Subversion repository
- When I run `vclog -f atom`
- Then the exit status should be 0
-
- Scenario: Subversion Changelog in YAML
- Given a suitable Subversion repository
- When I run `vclog -f yaml`
- Then the exit status should be 0
-
- Scenario: Subversion Changelog in JSON
- Given a suitable Subversion repository
- When I run `vclog -f json`
- Then the exit status should be 0
-
-
- Scenario: Subversion Release History
- Given a suitable Subversion repository
- When I run `vclog rel`
- Then the exit status should be 0
-
- Scenario: Subversion Release History in RDoc
- Given a suitable Subversion repository
- When I run `vclog rel -f rdoc`
- Then the exit status should be 0
-
- Scenario: Subversion Release History in Markdown
- Given a suitable Subversion repository
- When I run `vclog rel -f markdown`
- Then the exit status should be 0
-
- Scenario: Subversion Release History in HTML
- Given a suitable Subversion repository
- When I run `vclog rel -f html`
- Then the exit status should be 0
-
- Scenario: Subversion Release History in XML
- Given a suitable Subversion repository
- When I run `vclog rel -f xml`
- Then the exit status should be 0
-
- Scenario: Subversion Release History in Atom
- Given a suitable Subversion repository
- When I run `vclog rel -f atom`
- Then the exit status should be 0
-
- Scenario: Subversion Release History in YAML
- Given a suitable Subversion repository
- When I run `vclog rel -f yaml`
- Then the exit status should be 0
-
- Scenario: Subversion Release History in JSON
- Given a suitable Subversion repository
- When I run `vclog rel -f json`
- Then the exit status should be 0
-
diff --git a/work/deprecated/history.rb b/work/deprecated/history.rb
deleted file mode 100644
index 2ad5b89..0000000
--- a/work/deprecated/history.rb
+++ /dev/null
@@ -1,135 +0,0 @@
-module VCLog
-
- require 'vclog/core_ext'
- require 'vclog/changelog'
- require 'vclog/tag'
- require 'vclog/release'
- require 'erb'
-
- # A Release History is very similar to a ChangeLog.
- # It differs in that it is divided into releases with
- # version, release date and release note.
- #
- # The release version, date and release note can be
- # descerened from the underlying SCM by identifying
- # the hard tag commits.
- #
- # TODO: Extract output formating from delta parser. Later---Huh?
- #
- class History
-
- # Location of this file in the file system.
- DIR = File.dirname(__FILE__)
-
- #
- attr :repo
-
- ## Alternate title.
- #attr_accessor :title
-
- ## Current working version.
- #attr_accessor :version
-
- ## Exclude commit details.
- #attr_accessor :summary
-
- #
- def initialize(repo)
- @repo = repo
-
- #opts = OpenStruct.new(opts) if Hash === opts
-
- #@title = opts.title || "RELEASE HISTORY"
- #@extra = opts.extra
- #@version = opts.version
- #@level = opts.level || 0
- end
-
- # Tag list from version control system.
- def tags
- @tags ||= repo.tags
- end
-
- # Changelog object
- #def changelog
- # @changlog ||= repo.changelog #ChangeLog.new(changes)
- #end
-
- # Change list from version control system filter for level setting.
- def changes
- @changes ||= (
- if @repo.point
- repo.change_points
- else
- repo.changes
- end
- )
- end
-
- #
- def releases
- @releases ||= (
- rel = []
-
- tags = self.tags
-
- #ver = repo.bump(version)
- user = repo.user
- time = ::Time.now + (3600 * 24) # one day ahead
-
- tags << Tag.new(:name=>'HEAD', :id=>'HEAD', :date=>time, :who=>user, :msg=>"Current Development")
-
- # TODO: Do we need to add a Time.now tag?
- # add current verion to release list (if given)
- #previous_version = tags[0].name
- #if current_version < previous_version # TODO: need to use natural comparision
- # raise ArgumentError, "Release version is less than previous version (#{previous_version})."
- #end
- #rels << [current_version, current_release || Time.now]
- #rels = rels.uniq # only uniq releases
-
- # sort by release date
- tags = tags.sort{ |a,b| a.date <=> b.date }
-
- # organize into deltas
- delta = []
- last = nil
- tags.each do |tag|
- delta << [tag, [last, tag.commit_date]]
- last = tag.commit_date
- end
- # gather changes for each delta
- delta.each do |tag, (started, ended)|
- if started
- set = changes.select{ |c| c.date >= started && c.date < ended }
- #gt_vers, gt_date = gt.name, gt.date
- #lt_vers, lt_date = lt.name, lt.date
- #gt_date = Time.parse(gt_date) unless Time===gt_date
- #lt_date = Time.parse(lt_date) unless Time===lt_date
- #log = changelog.after(gt).before(lt)
- else
- #lt_vers, lt_date = lt.name, lt.date
- #lt_date = Time.parse(lt_date) unless Time===lt_date
- #log = changelog.before(lt_date)
- set = changes.select{ |c| c.date < ended }
- end
-
- rel << Release.new(tag, set)
- end
- rel
- )
- end
-
- # Group +changes+ by tag type.
- def groups(changes)
- @groups ||= changes.group_by{ |e| e.label } #type
- end
-
- #
- def to_h
- releases.map{ |rel| rel.to_h }
- end
-
- end
-
-end