libgit2 / libgit2/libgit2sharp

The Filter API contains singleton Entry-points which are agnostic to `FilterMode`, does having `Clean` and `Smudge` entry-points make sense?

未关闭
#1,135 7 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Stabilization
主要语言
C#
星标
3.5k
派生
925
PR 合并指标
30 天内没有已合并 PR

描述

Today the Filter object (the API we expose to lib consumers) contains the following entry-points:

  • virtual void Initialize()
  • virtual void Complete(string path, string root, Stream output)
  • virtual void Create(string path, string root, FilterMode)
  • virtual void Clean(string path, string root, Stream input, Stream output)
  • virtual void Smudge(string path, string root, Stream input, Stream output)

This is very uneven and, to my OCD, a fairly inconsistent API. I'm responsible and I'd like to change it, however some have already taken a dependency. In the spirit of #1103 I suggest changing the API to the following.

  • virtual void Initialize()
  • virtual void Complete(string root, string path, Stream output, FilterMode mode)
  • virtual void Create(string root, string path, FilterMode mode)
  • virtual void Apply(string root, string path, Stream input, Stream output, FilterMode mode)

I believe this is a simplified API which presents a consistent set of entry-points, and leaves the mode management up to the implementation of Filter. I'll happily make the changes and update the associated tests.

As a side note, I had a side-band discussion with @ethomson about how to handle the .gitattributes macros (example: [filter "lfs"] \n clean = git lfs clean %f \n smudge = git lfs smudge %f). While there are normal situations when you just know(tm) what to do on smudge and clean callbacks, ideally the filter would at least aware if the user has edited the values of the macro.

Assuming we can find a solution, whatever solution we'll find will likely end up impact this API. Perhaps then we should combine the two discussions here.

/CC @ammeep @shiftkey @nulltoken

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先检查公开的 Filter API 及其相关测试,issue 指出它们会受到拟议签名更改的影响。然后检查如何处理 .gitattributes 的 clean 和 smudge 宏;完成这项工作需要达成一致的 API 设计、更新依赖方并通过测试。

由索引模型根据 Issue 内容生成。

评估

技术栈
csharp, git
领域
backend-api-design, tooling
Issue 类型
重构
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
基本清楚
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。