aboutsummaryrefslogtreecommitdiffstats
path: root/fpga/.ci/templates/check_clean_repo_steps.yml
blob: 7ac034dd8c2e202e54999975a64aef3b00d76cbf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#
# Copyright 2021 Ettus Research, a National Instruments Brand
#
# SPDX-License-Identifier: LGPL-3.0-or-later
#
# Description:
#
#   Checks for a clean repository (no untracked or modified files).
#

parameters:
  # Directory to execute the commands in
  - name: directory
    type: string
    default: $(Agent.BuildDirectory)/s

steps:
# Windows based calls
- powershell: |
    # Using git status as a way to check for a clean repo can produce
    # misleading results when the line endings have been modified (XmlParse has
    # a tendency to modify line endings). "git diff" seems to produce more
    # reliable results, and the --exit-code is useful for detecting a change/no
    # change summary.

    # Check for modified files
    git diff --exit-code;          if (-not $?) {throw "git diff should be empty"}

    # Check for modified files that are staged
    git diff --cached --exit-code; if (-not $?) {throw "git diff of staged changes should be empty"}

    # Check for untracked files
    git add .                      # add all untracked files
    git diff --cached --exit-code; if (-not $?) {throw "There should be no untracked files"}
  displayName: 'Check clean repository (Windows)'
  condition: eq( variables['Agent.OS'], 'Windows_NT' )
  workingDirectory: ${{ parameters.directory }}

# Linux based calls
- bash: |
    # Using git status as a way to check for a clean repo can produce
    # misleading results when the line endings have been modified (XmlParse has
    # a tendency to modify line endings). "git diff" seems to produce more
    # reliable results, and the --exit-code is useful for detecting a change/no
    # change summary.

    # Check for modified files
    git diff --exit-code          || exit 1

    # Checked for modified files that are staged
    git diff --cached --exit-code || exit 1

    # Check for untracked files
    git add .                      # add all untracked files
    git diff --cached --exit-code || exit 1
  displayName: 'Check clean repository (Linux)'
  condition: eq( variables['Agent.OS'], 'Linux' )
  workingDirectory: ${{ parameters.directory }}