165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
# File 'lib/git-version-bump.rb', line 165
def self.commit_date_version_string(use_local_dir = false)
commit_dates = run_command(["git", "-C", git_dir(use_local_dir).to_s, "log", "--no-show-signature", "--format=%at"], "getting dates of all commits").
split("\n").
map { |l| Time.at(Integer(l)).strftime("%Y%m%d") }
version_date = commit_dates.first
commit_count = commit_dates.select { |d| d == version_date }.length - 1
dirty_suffix = if dirty_tree?
".dirty.#{Time.now.strftime("%Y%m%d.%H%M%S")}"
else
""
end
return "0.#{version_date}.#{commit_count}#{dirty_suffix}"
rescue CommandFailure => ex
p :GVB_CDVS_CMD_FAIL, ex.output if debug?
if ex.output =~ /fatal: your current branch .* does not have any commits yet/
return "0.0.0.1.ENOCOMMITS"
else
raise VersionUnobtainable, "Could not get commit date-based version from git repository at #{git_dir(use_local_dir)}"
end
end
|