<commit_before>module Git where

import           Types

type GitRepoController = StateT GitRepoControllerState Sparker
data GitRepoControllerState = GitRepoControllerState {
        state_repo :: GitRepo
    }

runGitRepoController :: GitRepo -> GitRepoController a -> Sparker a
runGitRepoController repo func = do
    (a,_) <- runStateT (ensureRepoConsistency >> func) initialState
    return a
  where
    initialState :: GitRepoControllerState
    initialState = GitRepoControllerState {
            state_repo = repo
        }

ensureRepoConsistency :: GitRepoController ()
ensureRepoConsistency = do
    b <- isCloned
    if b
    then return () -- TODO, is there some way to check the integrity of the clone?
    else clone


isCloned :: GitRepoController Bool
isCloned = undefined

clone :: GitRepoController ()
clone = undefined

<commit_msg>copied the git code<commit_after>module Git where

import           System.Process (createProcess, shell)

import           Types

type GitRepoController = StateT GitRepoControllerState Sparker
data GitRepoControllerState = GitRepoControllerState {
        state_repo :: GitRepo
    }

runGitRepoController :: GitRepo -> GitRepoController a -> Sparker a
runGitRepoController repo func = do
    (a,_) <- runStateT (ensureRepoConsistency >> func) initialState
    return a
  where
    initialState :: GitRepoControllerState
    initialState = GitRepoControllerState {
            state_repo = repo
        }

ensureRepoConsistency :: GitRepoController ()
ensureRepoConsistency = do
    b <- isCloned
    if b
    then return () -- TODO, is there some way to check the integrity of the clone?
    else clone


isCloned :: GitRepoController Bool
isCloned = undefined

clone :: GitRepoController ()
clone = do
    repo <- gets state_repo
    let proc = shell $ "git clone " ++ show repo
    liftIO $ createProcess proc -- TODO wait for completion
    return ()

{'fraction_non_alphanumeric': 0.06345044572627163, 'fraction_numerical': 0.0, 'mean_word_length': 3.316742081447964, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7164087', 'n_tokens_mistral': 519, 'n_tokens_neox': 535, 'n_words': 169}