不知道诸位公司有没有这样的要求,所有的代码改动都需要加注释。 比如这样:
diff --git a/test.java b/test.java
index 70fd330..941c28d 100644
--- a/test.java
+++ b/test.java
@@ -1,5 +1,7 @@
public class HelloWorld {
public static void main(String[] args) {
- System.out.println("World, Hello!");
+ //zhangsan modify this for xxxx. 2023-02-26 start
+ System.out.println("Hello, World!");
+ //zhangsan modify this for xxxx. 2023-02-26 end
}
}
一般这种注释都是最终代码验证 ok 上传时才加。 如果代码的修改分散在很多不同的位置,那么加这个注释就很痛苦。
作为懒人,实在不想做这种麻烦事,于是写了个小脚本为添加到暂存区的修改添加注释:
./icomment path "comment"
发出来给各位大佬看看还有没有可以改进的地方,请尽情批评。 https://github.com/LinkTTT/icomment
![]() |
1
yolee599 210 天前 via Android
个人觉得这种注释很丑陋,多此一举,在 commit 填写描述就行了。
|
3
f1ush 210 天前
这要是重构改几十个文件的时候,不是看着人都麻了
|
![]() |
5
yan17 210 天前
公司这规定有点离谱啊,那要是后续再次修改,原来的注释要删除吗?
``` public static void main(String[] args) { //zhangsan modify this for xxxx. 2023-02-26 start + //zhangsan modify this for xxxx. 2023-02-27 start + System.out.println("Bye, World! "); + //zhangsan modify this for xxxx. 2023-02-27 end //zhangsan modify this for xxxx. 2023-02-26 end } } ``` 不删不就变这样了? |
![]() |
6
jfcherng 210 天前 ![]() 人肉 git blame?
|
8
aver4vex 210 天前
见过。也写过。确实比较头大。
|
![]() |
9
Pastsong 210 天前
是你们公司没人会用 git blame ?还是你们不用 git
|
![]() |
10
codingbody 210 天前 via iPhone
你们公司是人工版本控制嚒
|
![]() |
11
adoyle 210 天前 ![]() 喊你们的 CTO 来给大家解解惑。干嘛不用 git blame 或者 git log -S ,非要用这套蹩脚的注释。
如果一次提交只是删除代码是不是还得加上两行注释?多删改几次这文件不就满屏都是注释了? 如果不会用命令行操作,那我推荐 [git-history]( https://github.com/pomber/git-history),网页浏览变更历史,能本地部署,也有 VS Code 插件。不香么? |
![]() |
12
MajestySolor 210 天前
传说中的手工版本控制🐶
|
13
vsyf 210 天前 via Android
我猜是 aosp ,chromium 之类吧。
|
![]() |
14
darkengine 210 天前
前公司会让加 JIRA 上的 issue 号,其实比较合理,看到注释之后可以很方便的查到为什么要改。
|
![]() |
15
imnpc 210 天前
这个是在不用 git 的时代采用的方法, 有了 git 以后 不会在用这种了
|
![]() |
16
xuanbg 210 天前
没 Git 的时候也不需要这么写。又没写原来是啥 xx 改了啥,有个 P 用。
|
![]() |
17
Ally 210 天前
破规定,毫无用处,还拉低效率
|
18
cp19890714 209 天前
git 是摆设吗?
|
19
Andy223 209 天前
why don't u use 'git blame'?
|
![]() |
20
hxndg 209 天前 ![]() 我印象中,无论是 gitblame 还是 svn 都有渴死的功能吧。。。。
这以后代码多了就变成一层一层的梯田了吧。。。。 |
21
simplereasy 209 天前
大改动应该写
|
22
Goat121 209 天前
你领导咋想的啊,这种代码看一眼都觉得烦,还怎么工作
|