Extract VCS#revision_header
This commit is contained in:
parent
762fca9b12
commit
ee09f75a6b
@ -76,28 +76,7 @@ exit unless vcs
|
|||||||
}
|
}
|
||||||
when :revision_h
|
when :revision_h
|
||||||
Proc.new {|last, changed, modified, branch, title|
|
Proc.new {|last, changed, modified, branch, title|
|
||||||
short = vcs.short_revision(last)
|
vcs.revision_header(last, changed, modified, branch, title, limit: @limit)
|
||||||
if /[^\x00-\x7f]/ =~ title and title.respond_to?(:force_encoding)
|
|
||||||
title = title.dup.force_encoding("US-ASCII")
|
|
||||||
end
|
|
||||||
[
|
|
||||||
"#define RUBY_REVISION #{short.inspect}",
|
|
||||||
("#define RUBY_FULL_REVISION #{last.inspect}" unless short == last),
|
|
||||||
if branch
|
|
||||||
e = '..'
|
|
||||||
limit = @limit
|
|
||||||
name = branch.sub(/\A(.{#{limit-e.size}}).{#{e.size+1},}/o) {$1+e}
|
|
||||||
name = name.dump.sub(/\\#/, '#')
|
|
||||||
"#define RUBY_BRANCH_NAME #{name}"
|
|
||||||
end,
|
|
||||||
if title
|
|
||||||
title = title.dump.sub(/\\#/, '#')
|
|
||||||
"#define RUBY_LAST_COMMIT_TITLE #{title}"
|
|
||||||
end,
|
|
||||||
if modified
|
|
||||||
modified.utc.strftime('#define RUBY_RELEASE_DATETIME "%FT%TZ"')
|
|
||||||
end,
|
|
||||||
].compact
|
|
||||||
}
|
}
|
||||||
when :doxygen
|
when :doxygen
|
||||||
Proc.new {|last, changed|
|
Proc.new {|last, changed|
|
||||||
|
@ -204,6 +204,34 @@ class VCS
|
|||||||
revision_handler(rev).short_revision(rev)
|
revision_handler(rev).short_revision(rev)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def revision_header(last, changed, modified, branch, title, limit: 20)
|
||||||
|
short = short_revision(last)
|
||||||
|
if /[^\x00-\x7f]/ =~ title and title.respond_to?(:force_encoding)
|
||||||
|
title = title.dup.force_encoding("US-ASCII")
|
||||||
|
end
|
||||||
|
code = [
|
||||||
|
"#define RUBY_REVISION #{short.inspect}",
|
||||||
|
]
|
||||||
|
unless short == last
|
||||||
|
code << "#define RUBY_FULL_REVISION #{last.inspect}"
|
||||||
|
end
|
||||||
|
if branch
|
||||||
|
e = '..'
|
||||||
|
name = branch.sub(/\A(.{#{limit-e.size}}).{#{e.size+1},}/o) {$1+e}
|
||||||
|
name = name.dump.sub(/\\#/, '#')
|
||||||
|
code << "#define RUBY_BRANCH_NAME #{name}"
|
||||||
|
end
|
||||||
|
if title
|
||||||
|
title = title.dump.sub(/\\#/, '#')
|
||||||
|
code << "#define RUBY_LAST_COMMIT_TITLE #{title}"
|
||||||
|
end
|
||||||
|
if modified
|
||||||
|
t = modified.utc
|
||||||
|
code << t.strftime('#define RUBY_RELEASE_DATETIME "%FT%TZ"')
|
||||||
|
end
|
||||||
|
code
|
||||||
|
end
|
||||||
|
|
||||||
class SVN < self
|
class SVN < self
|
||||||
register(".svn")
|
register(".svn")
|
||||||
COMMAND = ENV['SVN'] || 'svn'
|
COMMAND = ENV['SVN'] || 'svn'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user