aboutsummaryrefslogtreecommitdiff
path: root/.gitlab/scripts/ci-helpers.sh
blob: b07b7ade562c6a072495c4af7f70a361737c742f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/bash

# Fetch origin/main safely (no tags, no full history)
fetch_main() {
    git fetch --no-tags --unshallow origin main >/dev/null 2>&1
}

# Get list of changed files matching a glob (e.g. '*.php' or 'src/**/*.vue')
get_changed_files() {
  local base_branch="${BASE_BRANCH:-origin/main}"
  shift 0

  fetch_main

  git diff --name-only --diff-filter=AM "$base_branch"...HEAD -- "$@" | grep -v '^$' || true
}