You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/** * 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. **/
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 。。
#!/bin/bash # store content in license.txtif [ !-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. **/EOFfideclare -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"$1if [[ $?!= 0 ]];thenecho"failed for $1"fi
Activity
Iceyer commentedon Feb 1, 2016
Author/Maintainer都不用了?
snyh commentedon Feb 1, 2016
可以做一个CI检测吧. 实现起来也比较简单. 也能节省以后的人工复查问题
Auhtor/Maintainer就自动描生成吧. git shortlog -n -s -e | cut -f2- | sort
Iceyer commentedon Feb 1, 2016
也好,反正Copyright写了也不会有人想去修改的 😄
fasheng commentedon Feb 1, 2016
CI 检测不清楚好不好实现。。。
//+buildsnyh commentedon Feb 1, 2016
我很怀疑 jenkis已经有这方面的插件了. 我去检测检查.
自己实现的话,其实不需要那么准确, 比如前200行里面如果有Copyright的格式就算通过了. (即使判断错误也没多大个事.)
snyh commentedon Feb 1, 2016
@choldrim 看看自动化这个能玩不.
我们其他人先在 @fasheng 的带领下 人肉进行这个任务.
fasheng commentedon Feb 1, 2016
需要调整的项目列表如下,修改完成后在前面打上对号即可(应该有权限吧) :)
@jouyouyun
@kosl90
@Iceyer
@XuShaohua
@Match-Yang
@dragondjf
@hualet
@sbwtw
@pangpangpang3
@sonald
@fasheng
@snyh
dstore/appstore-webappsbwtw commentedon Feb 1, 2016
这个东西应该有小工具管理的吧
fasheng commentedon Feb 1, 2016
有工具,不过都不是太好用
fasheng commentedon Feb 1, 2016
忘了说,review topic 就用 improve-copyright 吧~
Iceyer commentedon Feb 1, 2016
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位置改成自己的
谨慎使用 😆
sbwtw commentedon Feb 1, 2016
要的就是这种神奇的小命令~
On 01/02/16 15:23, Iceyer wrote:
石博文
fasheng commentedon Feb 1, 2016
上面的命令只能给未添加过任何 Copyright 信息的项目使用啊,等下会构建个用于更新已有 Copyright 的bash 命令,不过也无法通吃。。。
fasheng commentedon Feb 1, 2016
把命令贴到 bash 即可,可以更新 go 源码中已有的 Copyright 内容,无法正确处理年份,直接写死的 2015 。。
sbwtw commentedon Feb 3, 2016
libdui 和 dde-control-center 已改,但我的确没有权限 :(
2 remaining items
Match-Yang commentedon Feb 4, 2016
我的也勾不上额
fasheng commentedon Feb 4, 2016
@Match-Yang 额,你还没加入组织,看 github 的系统提示…
Match-Yang commentedon Feb 4, 2016
什么组织,没有提示呀
fasheng commentedon Feb 4, 2016
你进入 github linuxdeepin 主页,会有 invitation 提示
Match-Yang commentedon Feb 4, 2016
好了
sonald commentedon Feb 4, 2016
@fasheng deepin-metacity 改copyright好么,原始代码都是第三方的
fasheng commentedon Feb 4, 2016
@sonald 嗯,只改我们自己创建的文件
sonald commentedon Feb 5, 2016
我用来改C代码的脚本,好费劲
fasheng commentedon Feb 5, 2016
👍
hualet commentedon Feb 15, 2016
搞定了,太不容易了。。。
fasheng commentedon Feb 16, 2016
感谢大家的协助, copyright 的格式问题基本处理完毕. 另今天花时间写了个检测工具把漏掉的文件又处理了一遍, 应该没什么太大问题了, 先关闭任务.
copyright 小工具的使用说明可以参考这里 https://github.com/linuxdeepin/team-robots/tree/master/update-copyright
(虽然来的有点晚, 不过至少下次不用这么折腾了~
manateelazycat commentedon Feb 16, 2016
路过点赞!
sonald commentedon Feb 16, 2016
话说update-copyright有个函数看着好眼熟啊:)
fasheng commentedon Feb 16, 2016
嘻嘻, 参考了曹哥的awk脚本 ;)