Skip to content

Commit

Permalink
Prevent multiple AIRACs being read
Browse files Browse the repository at this point in the history
  • Loading branch information
GeekPro101 committed Feb 3, 2023
1 parent 08dc34f commit a0e53d5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,16 @@ Larry Benwater
```

## Usage
The easiest way to use this is copy and paste the desired changelog list from [https://raw.githubusercontent.com/VATSIM-UK/UK-Sector-File/main/.github/CHANGELOG.md](https://raw.githubusercontent.com/VATSIM-UK/UK-Sector-File/main/.github/CHANGELOG.md) into a `changelog.md` file locally, and just run with `./UKSFCG`
There are two ways to use this program:
- Locally - copy and paste the desired changelog list from [https://raw.githubusercontent.com/VATSIM-UK/UK-Sector-File/main/.github/CHANGELOG.md](https://raw.githubusercontent.com/VATSIM-UK/UK-Sector-File/main/.github/CHANGELOG.md) into a `changelog.md` file locally, and just run with `./UKSFCG`
- Online - run the program using `./UKSFCG --url`, which will read from the default URL specified below

Flags:
- `--in` - sets the input file, optional, default `changelog.md`
- `--out` - sets the output file, optional, default `output.txt`
- `--url` - sets the url, optional, if `--url` is present but empty then it defaults to `https://raw.githubusercontent.com/VATSIM-UK/UK-Sector-File/main/.github/CHANGELOG.md`

The `--url` flag takes precedence over `--in`, so if both are specified, then it will read from online.

## Limitations
- If a contributor has been added in the format `- thanks to @John (John Smith) and Smith John`, Smith John would not be on the contributors list
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ require github.com/stretchr/testify v1.8.1

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/jessevdk/go-flags v1.5.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/jessevdk/go-flags v1.5.0 h1:1jKYvbxEjfUl0fmqTCOfonvskHHXMjBySTLW4y9LFvc=
github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand All @@ -10,6 +12,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4 h1:EZ2mChiOa8udjfp6rRmswTbtZN/QzUQp4ptM4rnjHvc=
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Expand Down
9 changes: 8 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,16 @@ func GetWebChangelog(urls string) []byte {
func GetChanges(filebytes []byte) []string {
changes := []string{}
split := strings.Split(string(filebytes), "\n") // split the document into newlines
airacnumbers := 0
numberReComp := regexp.MustCompile(numberRe)
for _, s := range split {
b := numberReComp.MatchString(s) // ensures that it isn't the AIRAC title
if airacnumbers >= 2 {
break // if we go through multiple AIRACs then stop
}
if strings.Contains(s, "#") {
airacnumbers = airacnumbers + 1
}
b := numberReComp.MatchString(s) // only match changelog entries
if b {
s = numberReComp.ReplaceAllString(s, "") // removes the number from the start
changes = append(changes, s)
Expand Down

0 comments on commit a0e53d5

Please sign in to comment.