一鍵更新所有項目 LICENSE 的 Copyright 時間( Shell Command)

2016-01-01 15:19:06 +08:00
 Elethom

http://blog.projectrhinestone.org/one-liner-for-changing-all-git-repos-license-times/

pwd=$(pwd);for file in ~/GitHub/*/LICENSE;do cd $(dirname $file);git checkout master;stash=$(git diff LICENSE);if [ -n "$stash" ];then git stash;fi;sed -i "" -e "s/\(Copyright (c) \)[0-9]\{4\}\(-[0-9]\{4\}\)*/\1$(git log $(git log --pretty=format:%H|tail -1) --date=format:%Y --format=%ad)-$(date +%Y)/" LICENSE;git commit -m "Update time for copyright message in license" LICENSE;if [ -n "$stash" ];then git stash pop;fi;git push;done;cd $pwd

自行修改路徑,隨便開個 term 窗口 paste 進去就可以了。 POSIX 兼容。 Tested on OS X Yosemite Version 10.10.5 (14F27).

效果:

3364 次点击
所在节点    分享创造
9 条回复
49
2016-01-01 15:22:34 +08:00
E 娘干的漂亮,我也去给好友的 gayhub 提几个 PRprprpr hhhhhhhhhhhhhhhhh
kn007
2016-01-01 15:25:46 +08:00
漂亮!
kumakiti
2016-01-01 15:26:03 +08:00
确实干的漂亮!
Elethom
2016-01-01 15:42:12 +08:00
@49
加油,少年!鑒於半個 V2EX 都把我 block 了你還有很多的機會。
wbsdty331
2016-01-01 16:30:19 +08:00
不升级 El 吗?
Elethom
2016-01-01 16:57:25 +08:00
@wbsdty331
暫時沒升級的需求就沒升級。畢竟不寫代碼了,不需要隨時跟進開發環境的版本。
Arthur2e5
2016-01-04 11:39:55 +08:00
用 pushd popd 比 cd 回去优雅啦。另外 quoting 。
Elethom
2016-01-04 11:45:38 +08:00
@Arthur2e5
喵 quoting 怎麼啦。
KexyBiscuit
2016-01-04 20:26:24 +08:00
@Elethom 不过是活跃用户的 1/2 ,不哭,摸头

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/247670

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX