Skip to content

Commit

Permalink
fix space behind comment prefix in emty lines
Browse files Browse the repository at this point in the history
  • Loading branch information
kuritka committed Mar 16, 2021
1 parent f7e2a79 commit 3e5310f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/inspect.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Copyright 2021 Absa Group Limited
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# 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.
#
#
# Generated by GoLic, for more details see: https://github.com/AbsaOSS/golic
name: Inspect [linters, tests]

Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Copyright 2021 Absa Group Limited
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# 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.
#
#
# Generated by GoLic, for more details see: https://github.com/AbsaOSS/golic
.PHONY: lint
lint:
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@ create `.licignore`
*

# But not these files...
!Dockerfile*
!Makefile
!*.go

# ...even if they are in subdirectories
!*/
````
And run **GOLIC**
Install and run **GOLIC**
```shell
# GO 1.16
go install github.com/AbsaOSS/[email protected].0
go install github.com/AbsaOSS/[email protected].1
golic inject -c="2021 MyCompany ltd."
```

Expand Down
8 changes: 4 additions & 4 deletions config.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Copyright 2021 Absa Group Limited
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# 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.
#
#
# Generated by GoLic, for more details see: https://github.com/AbsaOSS/golic
golic:
licenses:
Expand Down
6 changes: 5 additions & 1 deletion impl/inject/inject.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,11 @@ func getCommentedLicense(config *Config, o Options, file string) (string, error)
// `\r\n` -> `\r\n #`, `\n` -> `\n #`
content := strings.ReplaceAll(template,"\n",fmt.Sprintf("\n%s ", config.Golic.Rules[rule].Prefix))
content = strings.TrimSuffix(content, config.Golic.Rules[rule].Prefix+" ")
return config.Golic.Rules[rule].Prefix + " " + content,nil
content = config.Golic.Rules[rule].Prefix + " " + content
// "# \n" -> "#\n" // "# \r\n" -> "#\r\n"; some environments automatically remove spaces in empty lines. This makes problems in license PR's
content = strings.ReplaceAll(content,fmt.Sprintf("%s \n",config.Golic.Rules[rule].Prefix),fmt.Sprintf("%s\n",config.Golic.Rules[rule].Prefix))
content = strings.ReplaceAll(content,fmt.Sprintf("%s \r\n",config.Golic.Rules[rule].Prefix),fmt.Sprintf("%s\r\n",config.Golic.Rules[rule].Prefix))
return content,nil
}

func splitSource(source string) (firstLine, rest string){
Expand Down

0 comments on commit 3e5310f

Please sign in to comment.