Nicer list-forks output

This commit is contained in:
Julian Ospald 2020-01-31 19:34:05 +01:00
parent fadc0f84bf
commit 595758d653
No known key found for this signature in database
GPG Key ID: 511B62C09D50CD28
4 changed files with 23 additions and 9 deletions

View File

@ -12,11 +12,14 @@ import Data.Dates ( getCurrentDateTime
)
import Data.Functor ( (<&>) )
import Data.List
import Data.Maybe
import Data.Semigroup ( (<>) )
import qualified Data.Text as T
import Data.Time.Calendar
import Data.Time.Clock
import Data.Time.Clock.POSIX
import Data.Time.Format
import Data.Time.Format.ISO8601
import GHup
import GitHub.Auth
import GitHub.Data.Definitions
@ -160,8 +163,13 @@ main = do
Nothing -> pure Nothing
forks <- withExceptT show $ getForks mtime
let formatted = intercalate "\n"
$ fmap (\Repo {..} -> T.unpack . getUrl $ repoHtmlUrl) forks
let formatted = intercalate "\n" $ fmap
(\Repo {..} ->
(T.unpack . getUrl $ repoHtmlUrl) <> " " <> formatShow
(iso8601Format :: Format Day)
(utctDay $ fromJust repoUpdatedAt)
)
forks
liftIO $ putStrLn $ formatted
pure ()
case e of

View File

@ -1,4 +1,5 @@
constraints: any.Cabal ==2.4.0.1,
constraints: any.Cabal ==3.0.0.0,
Cabal -bundled-binary-generic,
any.IfElse ==0.85,
any.StateVar ==1.2,
any.abstract-deque ==0.3,
@ -25,6 +26,8 @@ constraints: any.Cabal ==2.4.0.1,
any.base ==4.12.0.0,
any.base-compat ==0.11.1,
any.base-orphans ==0.8.2,
any.base-unicode-symbols ==0.2.4.2,
base-unicode-symbols +base-4-8 -old-base,
any.base16-bytestring ==0.1.1.6,
any.basement ==0.0.11,
any.bifunctors ==5.5.7,
@ -51,9 +54,10 @@ constraints: any.Cabal ==2.4.0.1,
any.cryptonite ==0.26,
cryptonite -check_alignment +integer-gmp -old_toolchain_inliner +support_aesni +support_deepseq -support_pclmuldq +support_rdrand -support_sse,
any.data-default-class ==0.1.2.0,
any.dates ==0.2.3.0,
any.deepseq ==1.4.4.0,
any.deepseq-generics ==0.2.0.0,
any.directory ==1.3.3.0,
any.directory ==1.3.6.0,
any.distributive ==0.6.1,
distributive +semigroups +tagged,
any.dlist ==0.8.0.7,
@ -110,7 +114,7 @@ constraints: any.Cabal ==2.4.0.1,
any.pretty ==1.1.3.6,
any.pretty-terminal ==0.1.0.0,
any.primitive ==0.7.0.0,
any.process ==1.6.5.0,
any.process ==1.6.7.0,
any.profunctors ==5.5.1,
any.random ==1.1,
any.rts ==1.0,
@ -129,13 +133,14 @@ constraints: any.Cabal ==2.4.0.1,
any.streamly ==0.7.0,
streamly -benchmark -debug -dev -examples -examples-sdl -has-llvm -inspection -no-charts -no-fusion -streamk,
any.streamly-bytestring ==0.1.0.1,
any.syb ==0.7.1,
any.tagged ==0.8.6,
tagged +deepseq +transformers,
any.template-haskell ==2.14.0.0,
any.text ==1.2.3.1,
any.text-binary ==0.2.1.1,
any.th-abstraction ==0.3.1.0,
any.time ==1.8.0.2,
any.time ==1.9.3,
any.time-compat ==1.9.2.2,
time-compat -old-locale,
any.tls ==1.5.3,

View File

@ -30,7 +30,7 @@ library
, safe-exceptions ^>= 0.1
, streamly ^>= 0.7
, text ^>= 1.2
, time ^>= 1.8
, time ^>= 1.9
, unix ^>= 2.7
, utf8-string ^>= 1.0
, vector ^>= 0.12
@ -56,7 +56,7 @@ executable ghup
, pretty-terminal ^>= 0.1
, safe ^>= 0.3
, text ^>= 1.2
, time ^>= 1.8
, time ^>= 1.9
, utf8-string ^>= 1.0
hs-source-dirs: app
default-language: Haskell2010

View File

@ -47,6 +47,7 @@ import Data.ByteString ( ByteString )
import qualified Data.ByteString.UTF8 as UTF8
import qualified Data.ByteString.Lazy.UTF8 as LUTF8
import Data.Functor ( (<&>) )
import Data.List
import Data.Proxy
import qualified Data.Text as T
import qualified Data.Text.Encoding as E
@ -325,7 +326,7 @@ getForks :: (MonadIO m, MonadReader Settings m)
-> ExceptT Error m [Repo]
getForks mtime = do
repos <- githubAuth (currentUserReposR RepoPublicityAll FetchAll)
pure $ filter
pure $ sortBy (\x y -> compare (repoUpdatedAt y) (repoUpdatedAt x)) $ filter
(\case
Repo { repoFork = Just True, repoUpdatedAt = Just t } ->
maybe True (t >=) mtime