on master help sign in
.github/workflows/binaries.ymlnew file+39
since splitsnapshots
unifiedsplit
@@ -0,0 +1,39 @@
1+name: Build binaries
2+on:
3+ release:
4+ types: [published]
5+jobs:
6+ build:
7+ strategy:
8+ fail-fast: false
9+ matrix:
10+ os: [ubuntu-latest, macOS-latest, windows-latest]
11+ runs-on: ${{ matrix.os }}
12+ steps:
13+ - uses: actions/checkout@v2
14+ - uses: actions/setup-haskell@v1
15+ if: runner.os != 'Linux'
16+ with:
17+ ghc-version: '8.10.1'
18+ cabal-version: '3.2'
19+ - name: Build Linux binary
20+ if: runner.os == 'Linux'
21+ run: |
22+ docker run \
23+ -v $(pwd):/mnt -w /mnt \
24+ utdemir/ghc-musl:v14-ghc8101 \
25+ bash .github/workflows/build.sh
26+ - name: Build ${{ runner.os }} binary
27+ if: runner.os != 'Linux'
28+ shell: bash
29+ run: |
30+ cabal build exe:ormolu
31+ cp $(find dist-newstyle \( -name ormolu -o -name ormolu.exe \) -type f) ormolu
32+ - uses: actions/upload-release-asset@v1
33+ env:
34+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+ with:
36+ upload_url: ${{ github.event.release.upload_url }}
37+ asset_path: ormolu
38+ asset_name: ormolu-${{ runner.os }}
39+ asset_content_type: application/octet-stream
.github/workflows/build.shnew file+7
@@ -0,0 +1,7 @@
1+set -e
2+
3+cabal update
4+cabal build exe:ormolu --enable-executable-static --ghc-options="-split-sections"
5+
6+cp $(find dist-newstyle -name ormolu -type f) .
7+strip -s ormolu
CHANGELOG.md+5
@@ -1,3 +1,8 @@
1+## Unreleased
2+
3+* Ormolu no longer overwrites already formatted files. [PR
4+ 649](https://github.com/tweag/ormolu/pull/649).
5+
1## Ormolu 0.1.2.0
6## Ormolu 0.1.2.0
2
7
3* Fixed the bug when comments in different styles got glued together after
8* Fixed the bug when comments in different styles got glued together after
README.md+1−1
@@ -22,7 +22,7 @@ the following goals in mind:
22* That formatting style aims to result in minimal diffs while still
22* That formatting style aims to result in minimal diffs while still
23 remaining very close to “conventional” Haskell formatting people use.
23 remaining very close to “conventional” Haskell formatting people use.
24* Choose a style compatible with modern dialects of Haskell. As new Haskell
24* Choose a style compatible with modern dialects of Haskell. As new Haskell
25− extensions enter broad use, we may change the style to accomodate them.
25+ extensions enter broad use, we may change the style to accommodate them.
26* Idempotence: formatting already formatted code doesn't change it.
26* Idempotence: formatting already formatted code doesn't change it.
27* Be well-tested and robust to the point that it can be used in large
27* Be well-tested and robust to the point that it can be used in large
28 projects without exposing unfortunate, disappointing bugs here and there.
28 projects without exposing unfortunate, disappointing bugs here and there.
app/Main.hs+10−6
@@ -61,15 +61,19 @@ formatOne mode config = \case
61 -- 101 is different from all the other exit codes we already use.
61 -- 101 is different from all the other exit codes we already use.
62 exitWith (ExitFailure 101)
62 exitWith (ExitFailure 101)
63 Just inputFile -> do
63 Just inputFile -> do
64+ originalInput <- TIO.readFile inputFile
64− r <- ormoluFile config inputFile
65+ formattedInput <- ormoluFile config inputFile
65 case mode of
66 case mode of
66 Stdout ->
67 Stdout ->
67− TIO.putStr r
68+ TIO.putStr formattedInput
68− InPlace ->
69+ InPlace -> do
70+ -- Only write when the contents have changed, in order to avoid
71+ -- updating the modified timestamp if the file was already correctly
72+ -- formatted.
73+ when (formattedInput /= originalInput) $
69− TIO.writeFile inputFile r
74+ TIO.writeFile inputFile formattedInput
70 Check -> do
75 Check -> do
71− r' <- TIO.readFile inputFile
76+ when (formattedInput /= originalInput) $
72− when (r /= r') $
73 -- 100 is different to all the other exit code that are emitted
77 -- 100 is different to all the other exit code that are emitted
74 -- either from an 'OrmoluException' or from 'error' and
78 -- either from an 'OrmoluException' or from 'error' and
75 -- 'notImplemented'.
79 -- 'notImplemented'.