Skip to content

Commit

Permalink
Merge pull request #10 from rightscale/PHX-1688_crlf
Browse files Browse the repository at this point in the history
PHX-1688 Normalize crlf line endings for windows
  • Loading branch information
psschroeter authored Aug 7, 2019
2 parents f3993ac + 4ed90eb commit f3601b3
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ addons:
before_install:
# install latest mercurial client on Linux. Older clients have issues https://bitbucket.org/blog/deprecating-tlsv1-tlsv1-1-2018-12-01
- if [[ $TRAVIS_OS_NAME == linux ]]; then pyenv install --skip-existing 2.7.14 && pyenv rehash && pyenv local 2.7.14; fi
- if [[ $TRAVIS_OS_NAME == linux ]]; then virtualenv -p python2.7.14 python_env; fi
- if [[ $TRAVIS_OS_NAME == linux ]]; then virtualenv -p python2.7 python_env; fi
- if [[ $TRAVIS_OS_NAME == linux ]]; then source python_env/bin/activate; fi
- if [[ $TRAVIS_OS_NAME == linux ]]; then pip install --upgrade pip; fi
- if [[ $TRAVIS_OS_NAME == linux ]]; then pip install mercurial --upgrade; fi
Expand Down
4 changes: 4 additions & 0 deletions cmd/fpt/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v1.0.4 / 2019-08-07
-------------------
* Fix script command with CRLF line endings.

v1.0.3 / 2019-03-14
-------------------
* Fix errors for bad hostname in config.
Expand Down
7 changes: 6 additions & 1 deletion cmd/fpt/script.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func runScript(ctx context.Context, file, outfile, result, name string, options
if err != nil {
return err
}
src := string(srcBytes)
src := normalizeLineEndings(string(srcBytes))

wr, err := os.Create(outfile)
if err != nil {
Expand Down Expand Up @@ -395,3 +395,8 @@ func unquote(s string) string {
s = q.ReplaceAllString(s, "$1")
return s
}

func normalizeLineEndings(in string) string {
out := strings.Replace(in, "\r\n", "\n", -1)
return strings.Replace(out, "\r", "\n", -1)
}
2 changes: 1 addition & 1 deletion cmd/fpt/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type LatestVersions struct {
const (
UpdateGithubBaseUrl = "https://github.com/rightscale/policy_sdk"
UpdateGithubReleasesUrl = UpdateGithubBaseUrl + "/releases"
UpdateGithubChangeLogUrl = UpdateGithubBaseUrl + "/blob/master/ChangeLog.md"
UpdateGithubChangeLogUrl = UpdateGithubBaseUrl + "/blob/master/cmd/fpt/ChangeLog.md"
)

var (
Expand Down
16 changes: 8 additions & 8 deletions cmd/fpt/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ versions:
Expect(buffer.Contents()).To(BeEquivalentTo(`There is a new v3 version of fpt (v3.4.5), to upgrade run:
fpt update apply
See https://github.com/rightscale/policy_sdk/blob/master/ChangeLog.md or
See https://github.com/rightscale/policy_sdk/blob/master/cmd/fpt/ChangeLog.md or
https://github.com/rightscale/policy_sdk/releases for more information.
`))
})
Expand All @@ -165,7 +165,7 @@ https://github.com/rightscale/policy_sdk/releases for more information.
Expect(buffer.Contents()).To(BeEquivalentTo(`There is a new major version of fpt (v3.4.5), to upgrade run:
fpt update apply -m 3
See https://github.com/rightscale/policy_sdk/blob/master/ChangeLog.md or
See https://github.com/rightscale/policy_sdk/blob/master/cmd/fpt/ChangeLog.md or
https://github.com/rightscale/policy_sdk/releases for more information.
`))
})
Expand All @@ -177,7 +177,7 @@ https://github.com/rightscale/policy_sdk/releases for more information.
There is a new major version of fpt (v3.4.5), to upgrade run:
fpt update apply -m 3
See https://github.com/rightscale/policy_sdk/blob/master/ChangeLog.md or
See https://github.com/rightscale/policy_sdk/blob/master/cmd/fpt/ChangeLog.md or
https://github.com/rightscale/policy_sdk/releases for more information.
`))
})
Expand All @@ -190,7 +190,7 @@ https://github.com/rightscale/policy_sdk/releases for more information.
The latest v2 version of fpt is v2.3.4.
The latest v3 version of fpt is v3.4.5.
See https://github.com/rightscale/policy_sdk/blob/master/ChangeLog.md or
See https://github.com/rightscale/policy_sdk/blob/master/cmd/fpt/ChangeLog.md or
https://github.com/rightscale/policy_sdk/releases for more information.
`))
})
Expand All @@ -201,7 +201,7 @@ https://github.com/rightscale/policy_sdk/releases for more information.
The latest v2 version of fpt is v2.3.4.
The latest v3 version of fpt is v3.4.5; this is the version you are using!
See https://github.com/rightscale/policy_sdk/blob/master/ChangeLog.md or
See https://github.com/rightscale/policy_sdk/blob/master/cmd/fpt/ChangeLog.md or
https://github.com/rightscale/policy_sdk/releases for more information.
`))
})
Expand All @@ -213,7 +213,7 @@ The latest v2 version of fpt is v2.3.4.
The latest v3 version of fpt is v3.4.5; you are using v3.0.0, to upgrade run:
fpt update apply
See https://github.com/rightscale/policy_sdk/blob/master/ChangeLog.md or
See https://github.com/rightscale/policy_sdk/blob/master/cmd/fpt/ChangeLog.md or
https://github.com/rightscale/policy_sdk/releases for more information.
`))
})
Expand All @@ -225,7 +225,7 @@ The latest v2 version of fpt is v2.3.4; this is the version you are using!
The latest v3 version of fpt is v3.4.5; you are using v2.3.4, to upgrade run:
fpt update apply -m 3
See https://github.com/rightscale/policy_sdk/blob/master/ChangeLog.md or
See https://github.com/rightscale/policy_sdk/blob/master/cmd/fpt/ChangeLog.md or
https://github.com/rightscale/policy_sdk/releases for more information.
`))
})
Expand All @@ -238,7 +238,7 @@ The latest v2 version of fpt is v2.3.4; you are using v2.0.0, to upgrade run:
The latest v3 version of fpt is v3.4.5; you are using v2.0.0, to upgrade run:
fpt update apply -m 3
See https://github.com/rightscale/policy_sdk/blob/master/ChangeLog.md or
See https://github.com/rightscale/policy_sdk/blob/master/cmd/fpt/ChangeLog.md or
https://github.com/rightscale/policy_sdk/releases for more information.
`))
})
Expand Down

0 comments on commit f3601b3

Please sign in to comment.