Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions testdata/expected/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

puts "Hello world!"
1 change: 1 addition & 0 deletions testdata/expected/file.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

# Say hello
def hello():
Expand Down
1 change: 1 addition & 0 deletions testdata/expected/file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// =============================================================================

#include <iostream>
using namespace std;
Expand Down
1 change: 1 addition & 0 deletions testdata/expected/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// =============================================================================

#include <iostream>
using namespace std;
Expand Down
1 change: 1 addition & 0 deletions testdata/expected/file.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// =============================================================================

public class Hello
{
Expand Down
1 change: 1 addition & 0 deletions testdata/expected/file.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// =============================================================================

void main() {
print('Hello World!');
Expand Down
1 change: 1 addition & 0 deletions testdata/expected/file.el
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;; See the License for the specific language governing permissions and
;; limitations under the License.
;; =============================================================================

(message "Hello world!")
1 change: 1 addition & 0 deletions testdata/expected/file.erl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
% See the License for the specific language governing permissions and
% limitations under the License.
% ==============================================================================

-module(hello).
-export([hello_world/0]).
Expand Down
1 change: 1 addition & 0 deletions testdata/expected/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// =============================================================================

package main

Expand Down
1 change: 1 addition & 0 deletions testdata/expected/file.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// =============================================================================

application {
mainClass = 'com.google.helloworld'
Expand Down
1 change: 1 addition & 0 deletions testdata/expected/file.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

query HeroNameAndFriends {
hero {
Expand Down
1 change: 1 addition & 0 deletions testdata/expected/file.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// =============================================================================

def dummy_function() {
println "Hello world"
Expand Down
1 change: 1 addition & 0 deletions testdata/expected/file.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// =============================================================================

group "default" {
targets = ["build"]
Expand Down
1 change: 1 addition & 0 deletions testdata/expected/file.hh
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// =============================================================================

#define SOMETHING
1 change: 1 addition & 0 deletions testdata/expected/file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// =============================================================================

#define SOMETHING
1 change: 1 addition & 0 deletions testdata/expected/file.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-- =============================================================================

module Main where

Expand Down
1 change: 1 addition & 0 deletions testdata/expected/file.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;; See the License for the specific language governing permissions and
;; limitations under the License.
;; =============================================================================

; hello world lisp program.
(print "Hello World")
1 change: 1 addition & 0 deletions testdata/expected/file.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// =============================================================================

#import <Foundation/Foundation.h>

Expand Down
1 change: 1 addition & 0 deletions testdata/expected/file.mm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// =============================================================================

#import <Foundation/Foundation.h>

Expand Down
1 change: 1 addition & 0 deletions testdata/expected/file.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

with import <nixpkgs> {};
mkShell {
Expand Down
1 change: 1 addition & 0 deletions testdata/expected/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// =============================================================================

namespace App;
phpinfo();
1 change: 1 addition & 0 deletions testdata/expected/file.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// =============================================================================

syntax = "proto3";

Expand Down
1 change: 1 addition & 0 deletions testdata/expected/file.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

cdef void main():
print("Hello World!")
1 change: 1 addition & 0 deletions testdata/expected/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

print "Hello World!"
1 change: 1 addition & 0 deletions testdata/expected/file.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

def main() -> None:
print("Hello World!")
1 change: 1 addition & 0 deletions testdata/expected/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

puts "Hello world!"
1 change: 1 addition & 0 deletions testdata/expected/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// =============================================================================

fn main() {
println!("Hello World!");
Expand Down
1 change: 1 addition & 0 deletions testdata/expected/file.sdl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-- =============================================================================

-- This is a fake table.
CREATE TABLE Foo (
Expand Down
1 change: 1 addition & 0 deletions testdata/expected/file.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// =============================================================================

print("Hello, world!")
1 change: 1 addition & 0 deletions testdata/expected/file.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

resource "null_resource" "dummy" {}
1 change: 1 addition & 0 deletions testdata/expected/file.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

[package]
name = "not-a-real-crate"
1 change: 1 addition & 0 deletions testdata/expected/file1.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

FROM scratch
CMD ["echo", "hello world"]
1 change: 1 addition & 0 deletions testdata/expected/file1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

echo hello
1 change: 1 addition & 0 deletions testdata/expected/file2.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

FROM scratch
CMD ["echo", "hello world"]
1 change: 1 addition & 0 deletions testdata/expected/file2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

1 change: 1 addition & 0 deletions testdata/expected/file3.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

FROM microsoft/nanoserver
COPY testfile.txt c:\
Expand Down
27 changes: 26 additions & 1 deletion tmpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,36 @@ func executeTemplate(t *template.Template, d licenseData, top, mid, bot string)
fmt.Fprintln(&out, top)
}
s := bufio.NewScanner(&buf)
found_empty_line := false
for s.Scan() {
fmt.Fprintln(&out, strings.TrimRightFunc(mid+s.Text(), unicode.IsSpace))
line := strings.TrimRightFunc(s.Text(), unicode.IsSpace)
found_empty_line = found_empty_line || line == ""
fmt.Fprintln(&out, strings.TrimRightFunc(mid+line, unicode.IsSpace))
}
if bot != "" {
fmt.Fprintln(&out, bot)
} else if found_empty_line && len(mid) < 80 {
// Found empty lines in the license header, so there are multiple paragraphs in the license.
//
// If the license does not specify a bottom suffix, add a visual separation line to the
// license header from the following code. For example:
//
// top, mid, bot = "", "# ", ""
//
// # License Header
// # ============================
//
// Code starts here...
//
// top, mid, bot = "/**", " * ", " */"
//
// /**
// * License Header
// */
//
// Code starts here...
//
fmt.Fprintln(&out, mid+strings.Repeat("=", 80-len(mid)))
}
fmt.Fprintln(&out)
return out.Bytes(), nil
Expand Down
2 changes: 2 additions & 0 deletions tmpl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
================================================================================

`,
},
Expand Down Expand Up @@ -242,6 +243,7 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================================================

`,
},
Expand Down