<commit_before>#!/usr/bin/env bats

setup() {
  cd $WORKSPACE
}

setup_dirs() {
  if [ -f "_Cargo.toml" ]; then
    mv _Cargo.toml Cargo.toml
  fi

  if [ -d "_git" ]; then
    mv _git .git && git reset --hard master
  fi
}

@test "it runs" {
  run semantic-rs
  [ "$status" -eq 1 ]
}

@test "fails without Cargo.toml" {
  cd empty-dir
  run semantic-rs
  [ "$status" -eq 1 ]
}

@test "fails on non-git directories" {
  cd not-a-repo
  setup_dirs

  run semantic-rs
  [ "$status" -eq 1 ]
}

@test "fails with broken Cargo.toml" {
  cd broken-cargo-toml
  setup_dirs

  run semantic-rs
  [ "$status" -eq 1 ]
}

@test "Initializes to v1.0.0" {
  cd initial-release
  setup_dirs

  run semantic-rs
  [ "$status" -eq 0 ]
  run grep -q 'version = "1.0.0"' Cargo.toml
  [ "$status" -eq 0 ]
}

@test "Bumps to next minor" {
  cd next-minor
  setup_dirs

  run grep -q 'version = "1.0.0"' Cargo.toml
  [ "$status" -eq 0 ]

  run semantic-rs
  [ "$status" -eq 0 ]

  run grep -q 'version = "1.1.0"' Cargo.toml
  [ "$status" -eq 0 ]
}

@test "No bump when no new commits" {
  cd no-bump
  setup_dirs

  run grep -q 'version = "1.1.0"' Cargo.toml
  [ "$status" -eq 0 ]

  run semantic-rs
  [ "$status" -eq 0 ]
  [[ "$output" =~ "No version bump. Nothing to do" ]]

  run grep -q 'version = "1.1.0"' Cargo.toml
  [ "$status" -eq 0 ]
}

@test "No crash with malformed tags" {
  cd malformed-tag
  setup_dirs

  semantic-rs
}<commit_msg>chore: Test that commit is created<commit_after>#!/usr/bin/env bats

setup() {
  cd $WORKSPACE
}

setup_dirs() {
  if [ -f "_Cargo.toml" ]; then
    mv _Cargo.toml Cargo.toml
  fi

  if [ -d "_git" ]; then
    mv _git .git && git reset --hard master
  fi
}

@test "it runs" {
  run semantic-rs
  [ "$status" -eq 1 ]
}

@test "fails without Cargo.toml" {
  cd empty-dir
  run semantic-rs
  [ "$status" -eq 1 ]
}

@test "fails on non-git directories" {
  cd not-a-repo
  setup_dirs

  run semantic-rs
  [ "$status" -eq 1 ]
}

@test "fails with broken Cargo.toml" {
  cd broken-cargo-toml
  setup_dirs

  run semantic-rs
  [ "$status" -eq 1 ]
}

@test "Initializes to v1.0.0" {
  cd initial-release
  setup_dirs

  run semantic-rs
  [ "$status" -eq 0 ]
  run grep -q 'version = "1.0.0"' Cargo.toml
  [ "$status" -eq 0 ]
}

@test "Bumps to next minor" {
  cd next-minor
  setup_dirs

  run grep -q 'version = "1.0.0"' Cargo.toml
  [ "$status" -eq 0 ]

  run semantic-rs
  [ "$status" -eq 0 ]

  run grep -q 'version = "1.1.0"' Cargo.toml
  [ "$status" -eq 0 ]

  run git log --oneline --format=format:%s
  [ "${lines[0]}" = "Bump version to 1.1.0" ]
}

@test "No bump when no new commits" {
  cd no-bump
  setup_dirs

  run grep -q 'version = "1.1.0"' Cargo.toml
  [ "$status" -eq 0 ]

  run semantic-rs
  [ "$status" -eq 0 ]
  [[ "$output" =~ "No version bump. Nothing to do" ]]

  run grep -q 'version = "1.1.0"' Cargo.toml
  [ "$status" -eq 0 ]
}

@test "No crash with malformed tags" {
  cd malformed-tag
  setup_dirs

  semantic-rs
}
{'fraction_non_alphanumeric': 0.161650321271559, 'fraction_numerical': 0.021643557659790327, 'mean_word_length': 2.4637002341920375, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3085483', 'n_tokens_mistral': 1340, 'n_tokens_neox': 1244, 'n_words': 361}