Skip to content

统一调整源码中 Copyright 格式 #30

Closed

Description

@fasheng

现统一使用下面的 Copyright 格式,其中年份是当前文件创建时所在的年份,且后期无需累计(即不要更改为 2015-2016 或 2015, 2016)

/**
 * Copyright (C) 2015 Deepin Technology Co., Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 **/

若没有问题,随后会把需要调整的项目列表及负责人贴上。
@linuxdeepin/dde-team @linuxdeepin/app-team

Activity

  1. Iceyer commented on Feb 1, 2016

    @Iceyer
    Member

    Author/Maintainer都不用了?

  2. snyh commented on Feb 1, 2016

    @snyh
    Member

    可以做一个CI检测吧.  实现起来也比较简单.  也能节省以后的人工复查问题
    Auhtor/Maintainer就自动描生成吧. git shortlog -n -s -e | cut -f2- | sort

  3. Iceyer commented on Feb 1, 2016

    @Iceyer
    Member

    也好,反正Copyright写了也不会有人想去修改的 😄

  4. fasheng commented on Feb 1, 2016

    @fasheng
    ContributorAuthor

    CI 检测不清楚好不好实现。。。

    1. 先判断是不是有效的源码文件
    2. 判断头部有没有特定的 Copyright 信息,又分两步:
      1. 如果是 go 源码,要处理第一行 //+build
      2. 处理不同类型的 comment 格式
  5. snyh commented on Feb 1, 2016

    @snyh
    Member

    我很怀疑 jenkis已经有这方面的插件了.  我去检测检查.

    自己实现的话,其实不需要那么准确, 比如前200行里面如果有Copyright的格式就算通过了. (即使判断错误也没多大个事.)

  6. snyh commented on Feb 1, 2016

    @snyh
    Member

    @choldrim 看看自动化这个能玩不. 
    我们其他人先在 @fasheng 的带领下 人肉进行这个任务.

  7. fasheng commented on Feb 1, 2016

    @fasheng
    ContributorAuthor

    需要调整的项目列表如下,修改完成后在前面打上对号即可(应该有权限吧) :)

    @jouyouyun

    • dde/dde-api
    • go-lib

    @kosl90

    • dde/startdde
    • deepin-file-manager

    @Iceyer

    • deepin-boot-maker

    @XuShaohua

    • deepin-installer
    • deepin-gettext-tools

    @Match-Yang

    • dde/dde-dock
    • deepin-feedback

    @dragondjf

    • dde/dde-desktop
    • dde/dde-launcher

    @hualet

    • deepin-menu
    • deepin-notifications
    • deepin-movie
    • deepin-music
    • deepin-terminal

    @sbwtw

    • dde/dde-control-center
    • dde/libdui

    @pangpangpang3

    • dde/dde-session-ui
    • deepin-qml-widgets
    • deepin-screenshot
    • deepin-social-sharing

    @sonald

    • deepin-metacity
    • deepin-wm-switcher

    @fasheng

    • dde/dde-daemon

    @snyh

    • dstore/appstore-webapp
    • dstore/deepin-appstore
    • dstore/init-data
    • lastore/lastore-daemon
    • go-dbus-generator
    • go-gir-generator
  8. sbwtw commented on Feb 1, 2016

    @sbwtw

    这个东西应该有小工具管理的吧

  9. fasheng commented on Feb 1, 2016

    @fasheng
    ContributorAuthor

    有工具,不过都不是太好用

    • copyright-update - update copyright information in files
    • licensecheck - simple license checker for source files
    • licenseutils - Put copyright and license notices at the head of source code files
    • license-reconcile - tool to reconcile copyright file and source
  10. fasheng commented on Feb 1, 2016

    @fasheng
    ContributorAuthor

    忘了说,review topic 就用 improve-copyright 吧~

  11. Iceyer commented on Feb 1, 2016

    @Iceyer
    Member

    for f in $(find /tmp -name '.cpp' -or -name '.h');
    do
    cat ~/copyright.txt $f >$f.new && mv $f.new $f
    done

    tmp 和 ~/copyright.txt位置改成自己的
    谨慎使用 😆

  12. sbwtw commented on Feb 1, 2016

    @sbwtw

    要的就是这种神奇的小命令~

    On 01/02/16 15:23, Iceyer wrote:

    for f in $(find /tmp -name '/.cpp' -or -name '/.h');
    do
    cat ~/copyright.txt $f >$f.new && mv $f.new $f
    done

    谨慎使用 😆

    —
    Reply to this email directly or view it on GitHub
    #30 (comment).

    石博文

  13. fasheng commented on Feb 1, 2016

    @fasheng
    ContributorAuthor

    上面的命令只能给未添加过任何 Copyright 信息的项目使用啊,等下会构建个用于更新已有 Copyright 的bash 命令,不过也无法通吃。。。

  14. fasheng commented on Feb 1, 2016

    @fasheng
    ContributorAuthor
    begin='\/\*\*\n'   # => "\**"
    end=' \*\*\/\n'     # => " **/"
    words='Copyright'
    replace='/**
     * Copyright (C) 2015 Deepin Technology Co., Ltd.
     *
     * This program is free software; you can redistribute it and/or modify
     * it under the terms of the GNU General Public License as published by
     * the Free Software Foundation; either version 3 of the License, or
     * (at your option) any later version.
     **/'
    
    find . -type f -iname '*.go' | xargs perl -0777pe 's#'"${begin}"'(?:(?!'"${end}"').)*?'"${words}"'.*?\n'"${end}"'#'"${replace}"'\n#s' -i

    把命令贴到 bash 即可,可以更新 go 源码中已有的 Copyright 内容,无法正确处理年份,直接写死的 2015 。。

  15. sbwtw commented on Feb 3, 2016

    @sbwtw

    libdui 和 dde-control-center 已改,但我的确没有权限 :(

  16. 2 remaining items

  17. Match-Yang commented on Feb 4, 2016

    @Match-Yang

    我的也勾不上额

  18. fasheng commented on Feb 4, 2016

    @fasheng
    ContributorAuthor

    @Match-Yang 额,你还没加入组织,看 github 的系统提示…

  19. Match-Yang commented on Feb 4, 2016

    @Match-Yang

    什么组织,没有提示呀

  20. fasheng commented on Feb 4, 2016

    @fasheng
    ContributorAuthor

    你进入 github linuxdeepin 主页,会有 invitation 提示

  21. Match-Yang commented on Feb 4, 2016

    @Match-Yang

    好了

  22. sonald commented on Feb 4, 2016

    @sonald

    @fasheng deepin-metacity 改copyright好么,原始代码都是第三方的

  23. fasheng commented on Feb 4, 2016

    @fasheng
    ContributorAuthor

    @sonald 嗯,只改我们自己创建的文件

  24. sonald commented on Feb 5, 2016

    @sonald
    #!/bin/bash 
    
    # store content in license.txt
    if [ ! -f license.txt ]; then
    cat > license.txt <<EOF
    /**
     * Copyright (C) 2015 Deepin Technology Co., Ltd.
     *
     * This program is free software; you can redistribute it and/or modify
     * it under the terms of the GNU General Public License as published by
     * the Free Software Foundation; either version 3 of the License, or
     * (at your option) any later version.
     **/
    EOF
    
    fi
    
    declare -a range
    range=(`awk -e '
    $0 ~ /\/\*/ { start = NR; has_copyright = 0; }
    $0 ~ /copyright/i { has_copyright = 1; }
    $0 ~ /\*\// { 
        if (has_copyright) {
            end = NR;
            exit;
        }
        start = 0; 
        has_copyright = 0;
    }
    
    END { print start, end }
    ' $1`)
    
    #echo ${range[0]}
    #echo ${range[1]}
    
    sed -i -e "${range[0]},${range[1]}d" -e "${range[0]},${range[0]}r license.txt" $1
    if [[ $? != 0 ]]; then
        echo "failed for $1"
    fi

    我用来改C代码的脚本,好费劲

  25. fasheng commented on Feb 5, 2016

    @fasheng
    ContributorAuthor

    👍

  26. hualet commented on Feb 15, 2016

    @hualet
    Contributor

    搞定了,太不容易了。。。

  27. fasheng commented on Feb 16, 2016

    @fasheng
    ContributorAuthor

    感谢大家的协助, copyright 的格式问题基本处理完毕. 另今天花时间写了个检测工具把漏掉的文件又处理了一遍, 应该没什么太大问题了, 先关闭任务.

    copyright 小工具的使用说明可以参考这里 https://github.com/linuxdeepin/team-robots/tree/master/update-copyright
    (虽然来的有点晚, 不过至少下次不用这么折腾了~

  28. manateelazycat commented on Feb 16, 2016

    @manateelazycat

    路过点赞!

  29. sonald commented on Feb 16, 2016

    @sonald

    话说update-copyright有个函数看着好眼熟啊:)

  30. fasheng commented on Feb 16, 2016

    @fasheng
    ContributorAuthor

    嘻嘻, 参考了曹哥的awk脚本 ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions