使用坚固的 git 库时,如何将该差异作为提交应用到我的 dest 分支?
# @param src [Rugged::Object] - the rugged object or string to compare from
# @param dst [Rugged::Object] - the rugged object or string to compare to, defaults to parent
# @return [Rugged::Diff] a rugged diff object between src and dst
def create_diff(src, dst = nil)
src = repo.lookup(find_ref(src))
dst ||= repo.lookup(src.parents.first)
dst = find_ref(dst)
src.diff(dst)
end
# @param sha_or_ref [String] - the name or sha of the ref
# @return [String] the oid of the sha or ref
def find_ref(sha_or_ref)
case sha_or_ref
when Rugged::Object
sha_or_ref.oid
else
repo.rev_parse_oid(sha_or_ref)
end
end
有没有简单的方法来应用补丁或差异?似乎很愚蠢,我需要遍历 diff 中的每个更改并添加/rm 文件。