-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The `show-work` command is migrated to Haskell with tests.
- Loading branch information
Showing
24 changed files
with
1,990 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: Haskell Test CI | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
env: | ||
GHC_VERSION: 9.2.4 | ||
STACK_VERSION: 2.7.3 | ||
HLINT_VERSION: 3.3.6 | ||
|
||
jobs: | ||
tests: | ||
strategy: | ||
matrix: | ||
# os: [ubuntu-latest, macos-latest] | ||
os: [ubuntu-latest] | ||
runs-on: ${{ matrix.os }} | ||
name: "Quality pipeline" | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/cache@v3 | ||
name: Cache .stack | ||
with: | ||
path: ~/.stack | ||
key: ${{ runner.os }}-stack-global-${{ hashFiles('stack.yaml') }}-${{ hashFiles('package.yaml') }}-${{ hashFiles('**/*.hs') }} | ||
restore-keys: | | ||
${{ runner.os }}-stack-global- | ||
- uses: haskell/actions/setup@v2 | ||
with: | ||
ghc-version: '${{ env.GHC_VERSION }}' | ||
enable-stack: true | ||
stack-version: '${{ env.STACK_VERSION }}' | ||
- name: Install hlint | ||
if: ${{ matrix.os == 'ubuntu-latest' }} | ||
run: | | ||
wget -O /tmp/hlint-${{ env.HLINT_VERSION }}.tar.gz https://github.com/ndmitchell/hlint/releases/download/v${{ env.HLINT_VERSION }}/hlint-${{ env.HLINT_VERSION }}-x86_64-linux.tar.gz | ||
tar -xf /tmp/hlint-${{ env.HLINT_VERSION }}.tar.gz -C /tmp | ||
cp /tmp/hlint-${{ env.HLINT_VERSION }}/hlint ~/.ghcup/bin/hlint | ||
- name: Run hlint | ||
if: ${{ matrix.os == 'ubuntu-latest' }} | ||
run: hlint . | ||
- name: Build dependencies | ||
run: stack build --no-haddock --only-dependencies --fast --pedantic | ||
- name: Run tests | ||
run: stack test --fast --pedantic | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,6 @@ | |
tmp/ | ||
site/ | ||
version | ||
.stack-work/ | ||
dist-newstyle/ | ||
out/ |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
#!/usr/bin/env bash | ||
./workflows ci | ||
# ./workflows cidated upstream |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
#!/usr/bin/env bash | ||
./workflows generate-docs | ||
# ./workflows generate-docs | ||
stack build --no-haddock --only-dependencies --fast --pedantic | ||
stack test --fast --pedantic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import Distribution.Simple | ||
main = defaultMain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Main (main) where | ||
|
||
import Lib | ||
import Universum | ||
|
||
main :: IO () | ||
main = runCli |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
cabal-version: 1.12 | ||
|
||
-- This file has been generated from package.yaml by hpack version 0.35.0. | ||
-- | ||
-- see: https://github.com/sol/hpack | ||
|
||
name: elegant-git | ||
version: 1.0.0 | ||
description: Elegant Git is an assistant who carefully automates routine work with Git. See more on <https://elegant-git.bees-hive.org/> | ||
homepage: https://github.com/bees-hive/elegant-git#readme | ||
bug-reports: https://github.com/bees-hive/elegant-git/issues | ||
author: Dmytro Serdiuk | ||
maintainer: [email protected] | ||
copyright: 2017 Dmytro Serdiuk | ||
license: MIT | ||
license-file: LICENSE | ||
build-type: Simple | ||
extra-source-files: | ||
README.md | ||
LICENSE | ||
|
||
source-repository head | ||
type: git | ||
location: https://github.com/bees-hive/elegant-git | ||
|
||
library | ||
exposed-modules: | ||
Elegit.Cli.Action.ShowWork | ||
Elegit.Cli.Command | ||
Elegit.Cli.Parser | ||
Elegit.Git.Action | ||
Elegit.Git.Runner.Real | ||
Elegit.Git.Runner.Simulated | ||
Lib | ||
other-modules: | ||
Paths_elegant_git | ||
hs-source-dirs: | ||
src | ||
default-extensions: | ||
FlexibleContexts | ||
OverloadedStrings | ||
NoImplicitPrelude | ||
ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Werror=incomplete-patterns -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints | ||
build-depends: | ||
base >=4.7 && <5 | ||
, dlist | ||
, fmt | ||
, free | ||
, microlens | ||
, microlens-mtl | ||
, microlens-th | ||
, mtl | ||
, optparse-applicative | ||
, safe-exceptions | ||
, text | ||
, transformers | ||
, typed-process | ||
, universum | ||
default-language: Haskell2010 | ||
|
||
executable git-elegant | ||
main-is: Main.hs | ||
other-modules: | ||
Paths_elegant_git | ||
hs-source-dirs: | ||
app | ||
default-extensions: | ||
FlexibleContexts | ||
OverloadedStrings | ||
NoImplicitPrelude | ||
ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Werror=incomplete-patterns -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N | ||
build-depends: | ||
base >=4.7 && <5 | ||
, dlist | ||
, elegant-git | ||
, fmt | ||
, free | ||
, microlens | ||
, microlens-mtl | ||
, microlens-th | ||
, mtl | ||
, optparse-applicative | ||
, safe-exceptions | ||
, text | ||
, transformers | ||
, typed-process | ||
, universum | ||
default-language: Haskell2010 | ||
|
||
test-suite elegant-git-test | ||
type: exitcode-stdio-1.0 | ||
main-is: Spec.hs | ||
other-modules: | ||
Elegit.Cli.Action.ShowWorkSpec | ||
Elegit.Git.Runner.SimulatedSpec | ||
Paths_elegant_git | ||
hs-source-dirs: | ||
test | ||
default-extensions: | ||
FlexibleContexts | ||
OverloadedStrings | ||
NoImplicitPrelude | ||
ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Werror=incomplete-patterns -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N | ||
build-depends: | ||
base >=4.7 && <5 | ||
, dlist | ||
, elegant-git | ||
, fmt | ||
, free | ||
, hspec | ||
, microlens | ||
, microlens-mtl | ||
, microlens-th | ||
, mtl | ||
, optparse-applicative | ||
, safe-exceptions | ||
, text | ||
, transformers | ||
, typed-process | ||
, universum | ||
default-language: Haskell2010 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="HASKELL_MODULE" version="4"> | ||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/app" isTestSource="false" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | ||
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" /> | ||
<excludeFolder url="file://$MODULE_DIR$/.stack-work" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
</component> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
cradle: | ||
stack: | ||
- path: "./src" | ||
component: "elegant-git:lib" | ||
|
||
- path: "./app/Main.hs" | ||
component: "elegant-git:exe:elegant-git-exe" | ||
|
||
- path: "./app/Paths_elegant_git.hs" | ||
component: "elegant-git:exe:elegant-git-exe" | ||
|
||
- path: "./test" | ||
component: "elegant-git:test:elegant-git-test" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
name: elegant-git | ||
version: 1.0.0 | ||
github: "bees-hive/elegant-git" | ||
license: MIT | ||
author: "Dmytro Serdiuk" | ||
maintainer: "[email protected]" | ||
copyright: "2017 Dmytro Serdiuk" | ||
|
||
extra-source-files: | ||
- README.md | ||
- LICENSE | ||
|
||
# Metadata used when publishing your package | ||
# synopsis: Short description of your package | ||
# category: Web | ||
|
||
# To avoid duplicated efforts in documentation and dealing with the | ||
# complications of embedding Haddock markup inside cabal files, it is | ||
# common to point users to the README.md file. | ||
description: Elegant Git is an assistant who carefully automates routine work with Git. See more on <https://elegant-git.bees-hive.org/> | ||
|
||
dependencies: | ||
- base >= 4.7 && < 5 | ||
|
||
- universum | ||
- text | ||
- safe-exceptions | ||
- fmt | ||
- transformers | ||
- mtl | ||
- free | ||
- dlist | ||
- microlens | ||
- microlens-mtl | ||
- microlens-th | ||
|
||
- optparse-applicative | ||
- typed-process | ||
|
||
default-extensions: | ||
- FlexibleContexts | ||
- OverloadedStrings | ||
- NoImplicitPrelude | ||
|
||
ghc-options: | ||
- -Wall | ||
- -Wcompat | ||
- -Widentities | ||
- -Wincomplete-record-updates | ||
- -Werror=incomplete-patterns | ||
- -Wmissing-home-modules | ||
- -Wpartial-fields | ||
- -Wredundant-constraints | ||
|
||
library: | ||
source-dirs: src | ||
|
||
executables: | ||
git-elegant: | ||
main: Main.hs | ||
source-dirs: app | ||
ghc-options: | ||
- -threaded | ||
- -rtsopts | ||
- -with-rtsopts=-N | ||
dependencies: | ||
- elegant-git | ||
|
||
tests: | ||
elegant-git-test: | ||
main: Spec.hs | ||
source-dirs: test | ||
ghc-options: | ||
- -threaded | ||
- -rtsopts | ||
- -with-rtsopts=-N | ||
dependencies: | ||
- elegant-git | ||
- hspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
module Elegit.Cli.Action.ShowWork where | ||
|
||
import Control.Monad.Free.Class | ||
import qualified Data.Text as T | ||
import qualified Elegit.Git.Action as GA | ||
import Fmt | ||
import Universum | ||
|
||
-- | Exectuion description of the AquireRepository action | ||
cmd :: (MonadFree GA.GitF m) => m () | ||
cmd = do | ||
currentBranch <- GA.currentBranch | ||
mCurrentUpstream <- GA.branchUpstream currentBranch | ||
branchWithLatestChanges <- GA.freshestDefaultBranch | ||
logs <- GA.log GA.LogOneLine branchWithLatestChanges currentBranch | ||
changes <- GA.status GA.StatusShort | ||
stashes <- GA.stashList | ||
|
||
GA.reportInfo ">>> Branch refs:" | ||
GA.reportInfo (fmt "local: "+|currentBranch|+"") | ||
case mCurrentUpstream of | ||
Just currentUpstream -> GA.reportInfo (fmt "remote: "+|currentUpstream|+"") | ||
Nothing -> pass | ||
|
||
GA.reportInfo "" | ||
|
||
unless (null logs) $ do | ||
GA.reportInfo (fmt ">>> New commits (comparing to "+|branchWithLatestChanges|+" branch):") | ||
GA.print $ T.intercalate "\n" logs | ||
GA.reportInfo "" | ||
|
||
unless (null changes) $ do | ||
GA.reportInfo ">>> Uncommitted modifications:" | ||
GA.print $ T.intercalate "\n" changes | ||
GA.reportInfo "" | ||
|
||
unless (null stashes) $ do | ||
GA.reportInfo ">>> Available stashes:" | ||
GA.print $ T.intercalate "\n" stashes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module Elegit.Cli.Command where | ||
|
||
data ElegitCommand | ||
= ShowWorkCommand |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module Elegit.Cli.Parser where | ||
|
||
import Elegit.Cli.Command (ElegitCommand (ShowWorkCommand)) | ||
import Options.Applicative | ||
import Universum | ||
|
||
|
||
type Command a = Mod CommandFields a | ||
|
||
|
||
showWorkCommand :: Command ElegitCommand | ||
showWorkCommand = | ||
command "show-work" $ | ||
flip info (progDesc "Prints HEAD state.") $ pure ShowWorkCommand | ||
|
||
|
||
dayToDayContributionsCommand :: Command ElegitCommand | ||
dayToDayContributionsCommand = | ||
commandGroup " make day-to-day contributions" | ||
<> showWorkCommand | ||
|
||
|
||
cli :: ParserInfo ElegitCommand | ||
cli = flip info mempty $ | ||
hsubparser dayToDayContributionsCommand <**> helper | ||
|
Oops, something went wrong.