add common GPL headers

This commit is contained in:
Jeff Carr 2025-02-01 11:38:22 -06:00
parent 899cbb3483
commit 22e0cbe022
10 changed files with 52 additions and 14 deletions

View File

@ -27,5 +27,8 @@ goimports:
clean:
rm -f go.*
gpl:
wit-test --witcom
check-git-clean:
@git diff-index --quiet HEAD -- || (echo "Git repository is dirty, please commit your changes first"; exit 1)

View File

@ -1,3 +1,6 @@
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0
package main
/*

View File

@ -1,3 +1,6 @@
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0
package main
import (

View File

@ -1,3 +1,6 @@
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0
package main
import (

View File

@ -1,3 +1,6 @@
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0
package main
import (

View File

@ -1,3 +1,7 @@
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0
package main
import (
@ -24,6 +28,7 @@ func doWITCOM() {
}
}
// add a common header for WIT files
// add a common header for WIT files
func addCommonHeader(filename string) error {
@ -34,13 +39,7 @@ func addCommonHeader(filename string) error {
return err
}
pf, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
defer pf.Close()
if err != nil {
log.Info("file open error. permissions?", filename, err)
return err
}
var newfile string
var start bool = true
var found bool
var done bool
@ -52,10 +51,10 @@ func addCommonHeader(filename string) error {
start = false
if strings.Contains(line, "WIT.COM") {
found = true
continue
} else {
fmt.Fprintln(pf, line)
newfile += fmt.Sprintln(line)
}
continue
}
// dump every other comment
@ -64,16 +63,28 @@ func addCommonHeader(filename string) error {
} else {
found = false
}
// print the header once
if !done {
fmt.Fprintln(pf, "// Copyright 2017-2025 WIT.COM Inc. All rights reserved.")
fmt.Fprintln(pf, "// Use of this source code is governed by the GPL 3.0")
fmt.Fprintln(pf, "")
fmt.Fprintln(pf, line)
newfile += fmt.Sprintln("// Copyright 2017-2025 WIT.COM Inc. All rights reserved.")
newfile += fmt.Sprintln("// Use of this source code is governed by the GPL 3.0")
newfile += fmt.Sprintln("")
done = true
}
fmt.Fprintln(pf, line)
newfile += fmt.Sprintln(line)
}
pf, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
if err != nil {
log.Info("file open error. permissions?", filename, err)
return err
}
// trim trailing empty lines from the new file
newfile = strings.TrimSpace(newfile)
fmt.Fprintln(pf, newfile)
pf.Close()
return nil
}

View File

@ -1,3 +1,6 @@
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0
package main
import (

View File

@ -1,3 +1,6 @@
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0
package main
import (

View File

@ -1,3 +1,6 @@
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0
package main
import (

View File

@ -1,3 +1,6 @@
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0
package main
import (