Compare commits
2 Commits
d3cd8bf333
...
649efea81c
Author | SHA1 | Date |
---|---|---|
Julian Ospald | 649efea81c | |
Julian Ospald | dc7604024f |
28
app/Main.hs
28
app/Main.hs
|
@ -31,6 +31,7 @@ import Options.Applicative
|
||||||
import Safe
|
import Safe
|
||||||
import System.Console.Pretty
|
import System.Console.Pretty
|
||||||
import System.Exit
|
import System.Exit
|
||||||
|
import Text.Layout.Table
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -123,12 +124,9 @@ lForkOpts = ListForkOptions <$> optional
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
let
|
let run e = do
|
||||||
run e = do
|
settings <- exceptT
|
||||||
settings <-
|
(\_ -> die
|
||||||
exceptT
|
|
||||||
(\_ ->
|
|
||||||
die
|
|
||||||
. color Red
|
. color Red
|
||||||
$ "Could not get settings, make sure to run 'ghup config' first"
|
$ "Could not get settings, make sure to run 'ghup config' first"
|
||||||
)
|
)
|
||||||
|
@ -163,13 +161,17 @@ main = do
|
||||||
Nothing -> pure Nothing
|
Nothing -> pure Nothing
|
||||||
|
|
||||||
forks <- withExceptT show $ getForks mtime
|
forks <- withExceptT show $ getForks mtime
|
||||||
let formatted = intercalate "\n" $ fmap
|
let formatted =
|
||||||
(\Repo {..} ->
|
gridString [column expand left def def
|
||||||
(T.unpack . getUrl $ repoHtmlUrl) <> " " <> formatShow
|
,column expand left def def]
|
||||||
(iso8601Format :: Format Day)
|
$ fmap
|
||||||
(utctDay $ fromJust repoUpdatedAt)
|
(\Repo {..} ->
|
||||||
)
|
[ (T.unpack . getUrl $ repoHtmlUrl)
|
||||||
forks
|
, formatShow (iso8601Format :: Format Day)
|
||||||
|
(utctDay $ fromJust repoUpdatedAt)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
forks
|
||||||
liftIO $ putStrLn $ formatted
|
liftIO $ putStrLn $ formatted
|
||||||
pure ()
|
pure ()
|
||||||
case e of
|
case e of
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
packages: ./ghup.cabal
|
packages: ./ghup.cabal
|
||||||
|
|
||||||
with-compiler: ghc-8.6.5
|
with-compiler: ghc-8.6.5
|
||||||
|
|
||||||
|
index-state: 2020-01-31T21:11:24Z
|
||||||
|
|
|
@ -54,6 +54,7 @@ constraints: any.Cabal ==3.0.0.0,
|
||||||
any.cryptonite ==0.26,
|
any.cryptonite ==0.26,
|
||||||
cryptonite -check_alignment +integer-gmp -old_toolchain_inliner +support_aesni +support_deepseq -support_pclmuldq +support_rdrand -support_sse,
|
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.data-default-class ==0.1.2.0,
|
||||||
|
any.data-default-instances-base ==0.1.0.1,
|
||||||
any.dates ==0.2.3.0,
|
any.dates ==0.2.3.0,
|
||||||
any.deepseq ==1.4.4.0,
|
any.deepseq ==1.4.4.0,
|
||||||
any.deepseq-generics ==0.2.0.0,
|
any.deepseq-generics ==0.2.0.0,
|
||||||
|
@ -134,6 +135,7 @@ constraints: any.Cabal ==3.0.0.0,
|
||||||
streamly -benchmark -debug -dev -examples -examples-sdl -has-llvm -inspection -no-charts -no-fusion -streamk,
|
streamly -benchmark -debug -dev -examples -examples-sdl -has-llvm -inspection -no-charts -no-fusion -streamk,
|
||||||
any.streamly-bytestring ==0.1.0.1,
|
any.streamly-bytestring ==0.1.0.1,
|
||||||
any.syb ==0.7.1,
|
any.syb ==0.7.1,
|
||||||
|
any.table-layout ==0.8.0.5,
|
||||||
any.tagged ==0.8.6,
|
any.tagged ==0.8.6,
|
||||||
tagged +deepseq +transformers,
|
tagged +deepseq +transformers,
|
||||||
any.template-haskell ==2.14.0.0,
|
any.template-haskell ==2.14.0.0,
|
||||||
|
|
|
@ -55,6 +55,7 @@ executable ghup
|
||||||
, optparse-applicative ^>= 0.15
|
, optparse-applicative ^>= 0.15
|
||||||
, pretty-terminal ^>= 0.1
|
, pretty-terminal ^>= 0.1
|
||||||
, safe ^>= 0.3
|
, safe ^>= 0.3
|
||||||
|
, table-layout ^>= 0.8
|
||||||
, text ^>= 1.2
|
, text ^>= 1.2
|
||||||
, time ^>= 1.9
|
, time ^>= 1.9
|
||||||
, utf8-string ^>= 1.0
|
, utf8-string ^>= 1.0
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
status_message() {
|
||||||
|
printf "\\033[0;32m%s\\033[0m\\n" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
error_message() {
|
||||||
|
printf "\\033[0;31m%s\\033[0m\\n" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
|
||||||
|
CACHE_LOCATION="${HOME}/.cabal/packages/hackage.haskell.org/01-index.cache"
|
||||||
|
|
||||||
|
if [ ! -f "${CACHE_LOCATION}" ] ; then
|
||||||
|
error_message "${CACHE_LOCATION} does not exist, did you run 'cabal update'?"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "${SCRIPTPATH}/cabal.project" ] ; then
|
||||||
|
error_message "Could not find ${SCRIPTPATH}/cabal.project, skipping index state update."
|
||||||
|
exit 3
|
||||||
|
fi
|
||||||
|
|
||||||
|
cabal v2-update
|
||||||
|
|
||||||
|
arch=$(getconf LONG_BIT)
|
||||||
|
|
||||||
|
case "${arch}" in
|
||||||
|
32)
|
||||||
|
byte_size=4
|
||||||
|
magic_word="CABA1002"
|
||||||
|
;;
|
||||||
|
64)
|
||||||
|
byte_size=8
|
||||||
|
magic_word="00000000CABA1002"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
error_message "Unknown architecture (long bit): ${arch}"
|
||||||
|
exit 2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# This is the logic to parse the binary format of 01-index.cache.
|
||||||
|
# The first word is a magic 'caba1002', the second one is the timestamp in unix epoch.
|
||||||
|
# Better than copying the cabal-install source code.
|
||||||
|
if [ "$(xxd -u -p -l${byte_size} -s 0 "${CACHE_LOCATION}")" != "${magic_word}" ] ; then
|
||||||
|
error_message "Magic word does not match!"
|
||||||
|
exit 4
|
||||||
|
fi
|
||||||
|
cache_timestamp=$(echo "ibase=16;obase=A;$(xxd -u -p -l${byte_size} -s ${byte_size} "${CACHE_LOCATION}")" | bc)
|
||||||
|
|
||||||
|
# If we got junk from the binary file, this should fail.
|
||||||
|
cache_date=$(date --utc --date "@${cache_timestamp}" "+%FT%TZ")
|
||||||
|
|
||||||
|
|
||||||
|
status_message "Updating index state in ${SCRIPTPATH}/cabal.project"
|
||||||
|
|
||||||
|
if grep -q "^index-state: .*" "${SCRIPTPATH}/cabal.project" ; then
|
||||||
|
awk '/index-state:/ {gsub(/.*/, "index-state: '${cache_date}'")}; { print }' "${SCRIPTPATH}/cabal.project" > "${SCRIPTPATH}/cabal.project.tmp"
|
||||||
|
mv "${SCRIPTPATH}/cabal.project.tmp" "${SCRIPTPATH}/cabal.project"
|
||||||
|
else
|
||||||
|
printf "index-state: %s\n" "${cache_date}" >> "${SCRIPTPATH}/cabal.project"
|
||||||
|
fi
|
||||||
|
|
Loading…
Reference in New Issue