Skip to content

Commit 3a5ba51

Browse files
committed
Add rule to assert that the current working directory is clean
1 parent 6437321 commit 3a5ba51

File tree

3 files changed

+109
-0
lines changed

3 files changed

+109
-0
lines changed

tools/make/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ include $(TOOLS_MAKE_LIB_DIR)/test-install/Makefile
9898
include $(TOOLS_MAKE_LIB_DIR)/tools-test/Makefile
9999
include $(TOOLS_MAKE_LIB_DIR)/tools-test-cov/Makefile
100100
include $(TOOLS_MAKE_LIB_DIR)/types-cov/Makefile
101+
include $(TOOLS_MAKE_LIB_DIR)/utils/Makefile
101102
include $(TOOLS_MAKE_LIB_DIR)/wasm/Makefile
102103
include $(TOOLS_MAKE_LIB_DIR)/workshops/Makefile
103104

tools/make/lib/utils/Makefile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#/
2+
# @license Apache-2.0
3+
#
4+
# Copyright (c) 2021 The Stdlib Authors.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#/
18+
19+
# RULES #
20+
21+
#/
22+
# Asserts that the current working directory is clean (i.e., does not contain uncommitted changes).
23+
#
24+
# @example
25+
# make assert-clean-working-directory
26+
#/
27+
assert-clean-working-directory:
28+
$(QUIET) if [[ -n "$(shell $(GIT) status --porcelain)" ]]; then \
29+
echo ''; \
30+
echo 'Error: invalid operation. Must have a clean working directory.'; \
31+
echo ''; \
32+
exit 1; \
33+
fi

tools/make/lib/utils/README.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2021 The Stdlib Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
21+
# Utilities
22+
23+
> Utility commands for use in [`make`][make] recipes.
24+
25+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
26+
27+
<section class="intro">
28+
29+
This directory contains [`make`][make] rules providing various utilities for use in [`make`][make] recipes.
30+
31+
</section>
32+
33+
<!-- /.intro -->
34+
35+
<!-- Usage documentation. -->
36+
37+
<section class="usage">
38+
39+
## Usage
40+
41+
```text
42+
Usage: make <command> [<ENV_VAR>=<value> <ENV_VAR>=<value> ...]
43+
```
44+
45+
### Commands
46+
47+
#### assert-clean-working-directory
48+
49+
Asserts that the current working directory is "clean" (i.e., does not contain any uncommitted changes)
50+
51+
```bash
52+
$ make assert-clean-working-directory
53+
```
54+
55+
</section>
56+
57+
<!-- /.usage -->
58+
59+
<!-- Section to include notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
60+
61+
<section class="notes">
62+
63+
</section>
64+
65+
<!-- /.notes -->
66+
67+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
68+
69+
<section class="links">
70+
71+
[make]: https://www.gnu.org/software/make/
72+
73+
</section>
74+
75+
<!-- /.links -->

0 commit comments

Comments
 (0)