<commit_before>defmodule Job do
  use GenServer

  require Logger

  defmacrop next_state(state, status, [do: block]) do
    quote do
      task = Task.async fn ->
        unquote(block)
      end
      Dict.put(unquote(state), :status, unquote(status))
        |> Dict.put(:task, task)
    end
  end

  def init({"", _}) do
    raise "problem"
  end
  def init({name, data}) do
    dir = Path.join(["/var", "local", "ashes", "build", name])
    repo = data["repository"]["url"]
    output = OutputCollector.new(self)
    state = %{dir: dir, data: data, output: output, env: [{"MIX_ENV", "prod"}], name: name}
    state = case File.dir?(dir) do
      true ->
        next_state(state, :clone) do
          System.cmd "git", ["fetch"], cd: dir, into: output, stderr_to_stdout: true
          System.cmd "mix", ["clean", repo, dir], cd: dir, into: output, stderr_to_stdout: true
        end
      false ->
        File.mkdir(dir)
        next_state(state, :clone) do
          System.cmd "git", ["clone", repo, dir], cd: dir, into: output, stderr_to_stdout: true<commit_msg>Restore login path in job<commit_after>defmodule Job do
  use GenServer

  require Logger

  defmacrop next_state(state, status, [do: block]) do
    quote do
      task = Task.async fn ->
        unquote(block)
      end
      Dict.put(unquote(state), :status, unquote(status))
        |> Dict.put(:task, task)
    end
  end

  def init({"", _}) do
    raise "problem"
  end
  def init({name, data}) do
    dir = Path.join(["/var", "local", "ashes", "build", name])
    repo = data["repository"]["url"]
    output = OutputCollector.new(self)
    {bash_env, 0} = System.cmd("/bin/bash", ["-l", "-c", "env"])
    path_env = String.split(bash_env)
      |> Enum.find(&String.starts_with?(&1, "PATH="))
      |> String.split("=")
      |> List.to_tuple
    state = %{
      dir: dir,
      data: data,
      output: output,
      env: [{"MIX_ENV", "prod"}, path_env],
      name: name}
    state = case File.dir?(dir) do
      true ->
        next_state(state, :clone) do
          System.cmd "git", ["fetch"], cd: dir, into: output, stderr_to_stdout: true
          System.cmd "mix", ["clean", repo, dir], cd: dir, into: output, stderr_to_stdout: true
        end
      false ->
        File.mkdir(dir)
        next_state(state, :clone) do
          System.cmd "git", ["clone", repo, dir], cd: dir, into: output, stderr_to_stdout: true
{'fraction_non_alphanumeric': 0.16181364392678868, 'fraction_numerical': 0.0008319467554076539, 'mean_word_length': 2.643939393939394, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, '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': '60751', 'n_tokens_mistral': 826, 'n_tokens_neox': 804, 'n_words': 224}