ruby - 从 git 提交生成发行说明
问题描述
我在下面创建了以下 rake 任务来为每个 sprint 生成我们的发行说明。
我将所有提交时间master
超过 2 周。
问题是当一个分支已经开发了超过 2 周的 sprint 时,较旧的提交将不包括在内。
谁能建议我可以得到这些提交的方法?
task :new_release_note do
puts "Creating new release note"
puts "..."
git_log = `git log --since="two weeks ago" --no-merges --format=%B`
git_log.gsub!(/^$\n/, '')
git_log.gsub!(/^/, "* ")
current_time = DateTime.now
current_date = current_time.strftime "%Y-%m-%d"
current_date_UK = current_time.strftime "%d-%m-%Y"
template = "__Release Notes__
=======================
#{current_date_UK}
__New Features__
----------------
* -
__Improvements__
----------------
* -
__Fixes__
---------
* -
__Change Log__
----------------
Detailed release notes below, listing all commit messages for this release.
#{git_log}
"
out_file = File.new("./doc/release_notes/release-notes-#{current_date}.md", "w")
out_file.puts(template)
if File.exist?(out_file)
puts "New release note generated successfully at /doc/release-notes/release-notes-#{current_date}.md"
else
puts "Error - file not generated."
end
end
解决方案
谁能建议我可以得到这些提交的方法?
几个选项:
git tag
git notes
git whatchanged
git tag
阅读关于什么是 git tag 以及如何使用它的答案:什么是 git tag、如何创建标签和如何签出 git 远程标签
简而言之: git tag 允许您标记提交,稍后可以执行合并。如你所知
git pull = git fetch + git merge
因此,一旦您使用标签标记了最后一次合并,您就可以从最后一次合并中提取所有更改
# "Merge" the last X commits based upon your previous tag
git cherry-pick <tag_name>..master
git notes
git notes
允许我们在不更新提交的 SHA-1 的情况下添加要提交的内容,这意味着我们可以在不修改 SHA-1 的情况下将内容附加到提交。
现在一旦你有了你的笔记,你就可以找到你之前“合并”的最后一个提交,并使用上面的cherry-pick
.
您可以搜索并找到您的笔记git log --grep
git whatchanged
git whatchanged
一旦您参考了什么是提交,您可以使用命令查看在此时间段内更新的文件列表
# Print out a list of files which was updated/added between the 2 commits
git whatchanged <TAG_NAME>...HEAD
推荐阅读
- vue.js - 无法设置 vuemapbox 地图的初始边界
- c++ - 如果输入大小太大,fstream::read() 读取为空
- mysql - 改进 covid-project 的 SQL 查询
- deep-learning - 减少唤醒词检测中的误报和置信度提高
- vim - taglist 适用于 gvim 而不是 vim
- python - Pandas:基于不同范围的棘手区间选择
- ios - 如何使 TableViewCell 动态化?
- laravel - 任何曾经在 laravel 中使用 Web Scraping 的人
- html - 如何使用 NodeJS 重定向到另一个页面
- compiler-errors - SwiftUI 初始化程序明显循环