【问题标题】:How do I apply a diff or patch file?如何应用差异文件或补丁文件?
【发布时间】:2017-07-07 22:32:15
【问题描述】:

当使用坚固的 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 文件。

【问题讨论】:

    标签: ruby git patch rugged


    【解决方案1】:

    考虑到:

    您必须等待该功能被移植到崎岖不平的环境中。
    最后一个official release v0.24.0 不包括0.24.4。

    【讨论】:

      猜你喜欢
      • 2020-08-18
      • 2011-11-21
      • 2011-01-21
      • 2011-05-12
      • 1970-01-01
      • 2011-01-28
      • 1970-01-01
      • 1970-01-01
      • 2010-10-05
      相关资源
      最近更新 更多