爱意满满的作品展示区。
Elethom

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

  •  1
     
  •   Elethom ·
    Elethom · Jan 1, 2016 · 4239 views
    This topic created in 3813 days ago, the information mentioned may be changed or developed.

    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).

    效果:

    GitHub Public Activity

    Supplement 1  ·  Jan 1, 2016

    起始年份從 commit log 獲取第一個 commit 的時間,當前年份用的 date 指令,默認的格式為 GitHub 生成的 Copyright (c) %Y Your Name

    9 replies    2016-01-04 20:26:24 +08:00
    49
        1
    49  
       Jan 1, 2016 via Android
    E 娘干的漂亮,我也去给好友的 gayhub 提几个 PRprprpr hhhhhhhhhhhhhhhhh
    kn007
        2
    kn007  
       Jan 1, 2016
    漂亮!
    kumakiti
        3
    kumakiti  
       Jan 1, 2016
    确实干的漂亮!
    Elethom
        4
    Elethom  
    OP
       Jan 1, 2016
    @49
    加油,少年!鑒於半個 V2EX 都把我 block 了你還有很多的機會。
    wbsdty331
        5
    wbsdty331  
       Jan 1, 2016
    不升级 El 吗?
    Elethom
        6
    Elethom  
    OP
       Jan 1, 2016
    @wbsdty331
    暫時沒升級的需求就沒升級。畢竟不寫代碼了,不需要隨時跟進開發環境的版本。
    Arthur2e5
        7
    Arthur2e5  
       Jan 4, 2016
    用 pushd popd 比 cd 回去优雅啦。另外 quoting 。
    Elethom
        8
    Elethom  
    OP
       Jan 4, 2016 via iPhone
    @Arthur2e5
    喵 quoting 怎麼啦。
    KexyBiscuit
        9
    KexyBiscuit  
       Jan 4, 2016 via Android
    @Elethom 不过是活跃用户的 1/2 ,不哭,摸头
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1177 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 42ms · UTC 23:29 · PVG 07:29 · LAX 16:29 · JFK 19:29
    ♥ Do have faith in what you're doing.