Can git commit signing implementation be updated to be easier to use?
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 48/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- git, ruby
调研方向
先阅读 Rugged::Commit.create、create_to_s 和 create_with_signature,然后跟踪对于新 bare 仓库,index.write 和引用更新的行为。完成的标准是:可以通过一次带有签名输入的 Commit 级调用创建签名 commit,同时保持 index 和 HEAD/引用的正常行为。
由索引模型根据 Issue 内容生成。
描述
Been trying to implement signing of commits in a project we use.
I have sort of gotten it to work but the implementation between a none signed commit and signed commit differs a lot and i would like it to become much easier so the code in the project i use gets cleaner.
Basically this is how we implemented none signed today, it works for a newly created bare repo also.
oid = repo.write("This is a blob.", :blob)
index = repo.index
index.read_tree(repo.head.target.tree)
index.add(:path => "README.md", :oid => oid, :mode => 0100644)
options = {}
options[:tree] = index.write_tree(repo)
options[:author] = { :email => "testuser@github.com", :name => 'Test Author', :time => Time.now }
options[:committer] = { :email => "testuser@github.com", :name => 'Test Author', :time => Time.now }
options[:message] ||= "Making a commit via Rugged!"
options[:parents] = repo.empty? ? [] : [ repo.head.target ].compact
options[:update_ref] = 'HEAD'
@commitref = Rugged::Commit.create(repo, options)
index.write
But to make signed commits in a new bare repo the first part is the same with options but alot after differs.
oid = repo.write("This is a blob.", :blob)
index = repo.index
index.read_tree(repo.head.target.tree)
index.add(:path => "README.md", :oid => oid, :mode => 0100644)
options = {}
options[:tree] = index.write_tree(repo)
options[:author] = { :email => "testuser@github.com", :name => 'Test Author', :time => Time.now }
options[:committer] = { :email => "testuser@github.com", :name => 'Test Author', :time => Time.now }
options[:message] ||= "Making a commit via Rugged!"
options[:parents] = repo.empty? ? [] : [ repo.head.target ].compact
options[:update_ref] = 'HEAD'
# Create a string of the contents to be commited.
content = Rugged::Commit.create_to_s(repo, options)
# Sign the string.
crypto = GPGME::Crypto.new(armor: true)
signature = crypto.detach_sign(content, signers: @cfg.sign_key).to_s.strip
# Create a commit using the string and signature.
@commitref = Rugged::Commit.create_with_signature(repo, content, signature, 'gpgsig')
# After doing this create_with_signature calling for index.write does not work.
# and i have to do this repo references else i cant see any commits when i do git log --show-signature
# Check if HEAD exists and handle accordingly
if repo.references.exist?("HEAD") && !repo.head_unborn?
# HEAD exists and points to a real branch
repo.references.update(repo.head.name, @commitref)
else
# HEAD doesn't exist or is unborn - create default branch
repo.references.create("refs/heads/master", @commitref)
end
I would like the implementation of signed commits to be as easy as doing a normal commit just that i have to specify the key i want to sign with.
e.g
# Just want a function i can call for as easy as Commit.create that signs my commits and update the reference on disk.
Rugged::Commit.commit_with_signature(repo, options, signature)
- 主要语言
- C
- 星标
- 2.3k
- 派生
- 293
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
libgit2/rugged 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 35/100
-
难度 4/5 3-5 天 新手友好度 35/100
-
难度 4/5 3-5 天 新手友好度 35/100
-
难度 3/5 1-2 天 新手友好度 48/100
-
LFS support? 未关闭
难度 5/5 一周以上 新手友好度 20/100
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
BasedHardware/omi#15662 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 84/100
-
bug
难度 2/5 1-3 小时 新手友好度 68/100
-
level/task module/gcp type/bug
难度 2/5 1-3 小时 新手友好度 85/100
-
难度 1/5 1 小时以内 新手友好度 86/100
hapostgres/pg_auto_failover#1190 ·