1 Star 0 Fork 1

github__fork/DotNetty

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
AddCopyrightHeaderToSourceFiles.ps1 1.83 KB
一键复制 编辑 原始数据 按行查看 历史
Aaron Stannard 提交于 2015-11-06 05:31 +08:00 . resolved conflicts with ByteBufferUtil
$lineBreak = "`r`n"
$noticeTemplate = "// Copyright (c) Microsoft. All rights reserved.$lineBreak// Licensed under the MIT license. See LICENSE file in the project root for full license information.$lineBreak$lineBreak"
$tokenToReplace = [regex]::Escape("[FileName]")
Function CreateFileSpecificNotice($sourcePath){
$fileName = Split-Path $sourcePath -Leaf
$fileSpecificNotice = $noticeTemplate -replace $tokenToReplace, $fileName
return $fileSpecificNotice
}
Function SourceFileContainsNotice($sourcePath){
$copyrightSnippet = [regex]::Escape("// Copyright (c) Microsoft")
$fileSpecificNotice = CreateFileSpecificNotice($sourcePath)
$arrMatchResults = Get-Content $sourcePath | Select-String $copyrightSnippet
if ($arrMatchResults -ne $null -and $arrMatchResults.count -gt 0){
return $true
}
else{
return $false
}
}
Function AddHeaderToSourceFile($sourcePath) {
# "Source path is: $sourcePath"
$containsNotice = SourceFileContainsNotice($sourcePath)
# "Contains notice: $containsNotice"
if ($containsNotice){
#"Source file already contains notice -- not adding"
}
else {
#"Source file does not contain notice -- adding"
$noticeToInsert = CreateFileSpecificNotice($sourcePath)
$fileLines = (Get-Content $sourcePath) -join $lineBreak
$content = $noticeToInsert + $fileLines + $lineBreak
$content | Out-File $sourcePath -Encoding utf8
}
}
$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
$parent = (get-item $scriptPath).Parent.FullName
$startingPath = "$parent\src"
Get-ChildItem $startingPath\*.cs -Recurse | Select FullName | Foreach-Object { AddHeaderToSourceFile($_.FullName)}
Get-ChildItem $startingPath\*.fs -Recurse | Select FullName | Foreach-Object { AddHeaderToSourceFile($_.FullName)}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/github__fork/DotNetty.git
git@gitee.com:github__fork/DotNetty.git
github__fork
DotNetty
DotNetty
dev

搜索帮助