如何(不显眼地)在编辑器/IDE 中指定提交消息

发布于 2024-08-22 13:06:12 字数 378 浏览 4 评论 0原文

背景:我当前使用的文本编辑器没有内置的 git 支持。尽管如此,它支持用户创建的插件,因此我制作了一个插件,以便在每次保存文件时自动提交到存储库。

虽然自动保存到存储库很简单,但提交消息目前不是很有用,它们只是用文本“自动保存”作为提交消息来标记当前日期和时间。

在研究这种情况时,我认为了解文本编辑器如何处理让用户每次保存文件时指定不同的提交消息(如果需要)的问题可能会有所帮助。

问题:文本编辑器如何不引人注意地允许用户指定非自动提交消息?用户是否会看到一个弹出对话框?编辑器是否提供了一个暂存缓冲区,该缓冲区除了充当提交消息的临时存储之外什么也不做?有没有一种方法可以做到这一点,而不会在一段时间后感觉像“导航屏幕”?

Background: the current text editor i am using does not have built-in support for git. Nevertheless, it has support for user-created addons, so I made one for auto-commiting to the repository each time I save a file.

Although auto-saving to the repository is straightforward, the commit messages currently are not very useful, they just slap the current date and time with the text "auto saved" as the commit message.

In looking at this situation I thought it might be helpful to find out how text editors handle the issue of letting the user specify a different commit message each time they save a file (if wanted).

Question: How do text editors unobtrusively allow the user to specify a non-automated commit message? Does the user get presented with a pop-up dialog box? Does the editor provide a scratch buffer that does nothing but act as a temporary storage for the commit message? Is there a way this can be done without feeling like a "nag screen" after a while?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

挽你眉间 2024-08-29 13:06:12

每次保存文件时,您真的需要不同的消息吗?

大多数保存操作都是反射 CTRL+S 编辑过程的中间记录。
如果某个任务(错误修复、功能开发等)正在进行中,那么这些中间保存并不意味着会带来大量新信息。
如果系统地提交,那么从 Git1.7 开始,这些提交应该仅使用新的 fixup! 操作作为注释。

这样,一旦给定的任务完成,您就可以自动压缩所有这些提交,仅保留第一个提交的注释,并忽略该文件的所有后续提交的注释。

git rebase --interactive --autosquash

请参阅 修剪 GIT Checkins SO 问题。

Do you really need a different message each time you save a file?

Most of the save actions are reflex CTRL+S intermediate recording of the editing process.
If a certain task (bug fix, feature development, ...) is in progress, those intermediate saves are not meant to bring a lot of new information.
If systematically committed, those commits should, from Git1.7 forward, only use the new fixup! action as a comment.

That way, once a given task has been completed, you could automatically squash all those commits keeping only the comment of the first one, and ignoring the comments of all the following commits for that file.

git rebase --interactive --autosquash

See Trimming GIT Checkins SO question.

送君千里 2024-08-29 13:06:12

我认为你不需要太聪明就能得到你正在寻找的绝大多数东西。附加组件有两个路径,一个是自动保存,正如您当前使用通用自动保存提交消息所描述的那样。

第二个“有意”提交/保存,您作为用户请求提交条目的提交消息屏幕。这将是附加组件中的一个附加宏/热键/按钮,用于显式键入提交消息,其中“自动保存”功能就是自动保存。

跟踪并仅在有意保存和自动保存之间发生变化时才自动保存。简单明了,无需导航屏幕即可自动保存,并且可以灵活地添加显式提交消息。

祝你好运。

I think you can get the vast majority of what you are looking for without being too clever. How about two paths for the add-on, one auto-save as you currently have described with a generic auto save commit message.

A second "intentional" commit/save where you as the user are requesting the commit message screen for the commit entry. This would be an additional macro/hot-key/button from your add-on that you use for explicitly typing in the commit message where the "auto save" functionality is just that, auto save.

Keep track and only auto-save when changes between intentional saves and auto saves have occurred. Straightforward and gives you auto saves without nag screens with the flexibility to add explicit commit messages.

Best of luck.

还如梦归 2024-08-29 13:06:12

显然,这完全取决于您的编辑。

Visual Studio/TFS 可能不是源代码控制的最佳环境,但恕我直言,这一方面处理得很好。他们有一个“待更改”窗口,您可以在开发过程中编写提交消息,并且它会在不同的会话中记住它。

一种可能适合您情况的策略是在某处保留一个固定的“commitmessage.txt”文件,您的自动提交命令可以使用该文件(并且可能在提交后清除)。

That entirely depends on your editor obviously.

Visual Studio/TFS may not be the best environment for source control, but this one aspect is handled pretty well IMHO. They have a 'pending changes' window where you can write your commit message during your developments, and it remembers it over different sessions.

One strategy that might work in your situation is simply to keep a fixed 'commitmessage.txt' file somewhere, which your auto-commit command could use (and maybe clear after the commit).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文