mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-29 09:42:25 +00:00
* Adding explicit MPL license for sub-package. This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Adding explicit MPL license for sub-package. This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Updating the license from MPL to Business Source License. Going forward, this project will be licensed under the Business Source License v1.1. Please see our blog post for more details at https://hashi.co/bsl-blog, FAQ at www.hashicorp.com/licensing-faq, and details of the license at www.hashicorp.com/bsl. * add missing license headers * Update copyright file headers to BUS-1.1 * Fix test that expected exact offset on hcl file --------- Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com> Co-authored-by: Sarah Thompson <sthompson@hashicorp.com> Co-authored-by: Brian Kassouf <bkassouf@hashicorp.com>
60 lines
2.1 KiB
Bash
Executable File
60 lines
2.1 KiB
Bash
Executable File
#!/bin/bash
|
|
# Copyright (c) HashiCorp, Inc.
|
|
# SPDX-License-Identifier: BUSL-1.1
|
|
|
|
# This script validates if the git diff contains only docs/ui changes
|
|
|
|
event_type=$1 # GH event type (pull_request)
|
|
ref_name=$2 # branch reference that triggered the workflow
|
|
base_ref=$3 # PR branch base ref
|
|
|
|
contains() {
|
|
target=$1; shift
|
|
for i; do
|
|
if [[ "$i" == "$target" ]]; then
|
|
return 0
|
|
fi
|
|
done
|
|
return 1
|
|
}
|
|
|
|
if [[ "$event_type" == "pull_request" ]]; then
|
|
git fetch --no-tags --prune origin $base_ref
|
|
head_commit="HEAD"
|
|
base_commit="origin/$base_ref"
|
|
else
|
|
git fetch --no-tags --prune origin $ref_name
|
|
head_commit=$(git log origin/$ref_name --oneline | head -1 | awk '{print $1}')
|
|
base_commit=$(git log origin/$ref_name --oneline | head -2 | awk 'NR==2 {print $1}')
|
|
fi
|
|
|
|
# git diff with ... shows the differences between base_commit and head_commit starting at the last common commit
|
|
changed_dir=$(git diff $base_commit...$head_commit --name-only | awk -F"/" '{ print $1}' | uniq)
|
|
change_count=$(git diff $base_commit...$head_commit --name-only | awk -F"/" '{ print $1}' | uniq | wc -l)
|
|
|
|
# There are 4 main conditions to check:
|
|
#
|
|
# 1. more than two changes found, set the flags to false
|
|
# 2. doc only change
|
|
# 3. ui only change
|
|
# 4. two changes found, if either doc or ui does not exist in the changes, set both flags to false
|
|
|
|
if [[ $change_count -gt 2 ]]; then
|
|
echo "is_docs_change=false" >> "$GITHUB_OUTPUT"
|
|
echo "is_ui_change=false" >> "$GITHUB_OUTPUT"
|
|
elif [[ $change_count -eq 1 && "$changed_dir" == "website" ]]; then
|
|
echo "is_docs_change=true" >> "$GITHUB_OUTPUT"
|
|
echo "is_ui_change=false" >> "$GITHUB_OUTPUT"
|
|
elif [[ $change_count -eq 1 && "$changed_dir" == "ui" ]]; then
|
|
echo "is_ui_change=true" >> "$GITHUB_OUTPUT"
|
|
echo "is_docs_change=false" >> "$GITHUB_OUTPUT"
|
|
else
|
|
if ! contains "website" ${changed_dir[@]} || ! contains "ui" ${changed_dir[@]}; then
|
|
echo "is_docs_change=false" >> "$GITHUB_OUTPUT"
|
|
echo "is_ui_change=false" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "is_docs_change=true" >> "$GITHUB_OUTPUT"
|
|
echo "is_ui_change=true" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
fi
|