Skip to content

Commit 48accce

Browse files
authored
Merge pull request #221 from mbland/issue-template
Add GitHub ISSUE_TEMPLATE and CODEOWNERS files, and `./go goinfo` command
2 parents 64cddaf + f961983 commit 48accce

File tree

7 files changed

+155
-21
lines changed

7 files changed

+155
-21
lines changed

.github/CODEOWNERS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# This enables automatic code review requests per:
2+
# - https://help.github.com/articles/about-codeowners/
3+
# - https://help.github.com/articles/enabling-required-reviews-for-pull-requests/
4+
* @mbland

.github/ISSUE_TEMPLATE.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
## Due diligence
2+
3+
- [ ] I am familiar with the ["Reporting issues" section of
4+
CONTRIBUTING.md][reporting]
5+
- [ ] I have searched the [existing issues][issues] and haven't found one
6+
that matches what I'm reporting or requesting now.
7+
- [ ] If this is a bug report, I have searched the [Bash changelog][changes]
8+
for information that may explain or provide clues to the behavior I'm
9+
observing and reference it in the body of the report.
10+
11+
[reporting]: https://github.com/mbland/go-script-bash/blob/master/CONTRIBUTING.md#reporting-issues
12+
[issues]: https://github.com/mbland/go-script-bash/issues
13+
[changes]: https://tiswww.case.edu/php/chet/bash/CHANGES
14+
15+
## Framework, Bash, and operating system version information
16+
17+
```
18+
If this is a bug report, replace this preformatted section with the output from:
19+
20+
$ ./go goinfo
21+
22+
Otherwise remove this section altogether.
23+
```
24+
25+
## Description
26+
27+
Replace this text with a description of your bug report or feature request.
28+
29+
If this is a bug report, include any relevant command line steps, code snippets,
30+
or test cases to reproduce the issue.

CONTRIBUTING.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ been filed.
6666

6767
If you do find one...
6868

69-
[issues]: https://github.com/mbland/custom-links/issues
69+
[issues]: https://github.com/mbland/go-script-bash/issues
7070

7171
### Do not add a +1 comment!
7272

@@ -84,10 +84,11 @@ matching issue...
8484
Try to be as specific as possible about your environment and the problem you're
8585
observing. At a minimum, include:
8686

87-
- The version of bash you're using, from either `bash --version` or `echo
88-
$BASH_VERSION`
89-
- The version of the go-script-bash library you're using
87+
- The output from `./go goinfo`
9088
- Command line steps or code snippets that reproduce the issue
89+
- Any apparently relevant information from the [Bash changelog][bash-changes]
90+
91+
[bash-changes]: https://tiswww.case.edu/php/chet/bash/CHANGES
9192

9293
Also consider using:
9394

lib/platform

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ _@go.platform_ostype() {
4242
case "$OSTYPE" in
4343
darwin*)
4444
_GO_PLATFORM_ID='macos'
45+
_GO_PLATFORM_VERSION_ID="$(sw_vers -productVersion)"
4546
;;
4647
freebsd*)
4748
_GO_PLATFORM_ID='freebsd'
@@ -56,6 +57,10 @@ _@go.platform_ostype() {
5657
_GO_PLATFORM_ID="$OSTYPE"
5758
;;
5859
esac
60+
61+
if [[ -z "$_GO_PLATFORM_VERSION_ID" ]] && command -v 'uname' >/dev/null; then
62+
_GO_PLATFORM_VERSION_ID="$(uname -r)"
63+
fi
5964
}
6065

6166
_@go.platform() {

libexec/goinfo

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#! /usr/bin/env bash
2+
#
3+
# Prints go-script-bash, Bash, and operating system version information
4+
#
5+
# Useful for diagnosing problems and filing bug reports.
6+
#
7+
# More information may be gleaned from `uname`, as well as `sw_vers` on macOS,
8+
# but this includes the most often relevant information.
9+
10+
. "$_GO_USE_MODULES" 'format' 'platform'
11+
12+
_@go.goinfo() {
13+
local varnames=('_GO_CORE_VERSION'
14+
'BASH_VERSION'
15+
'OSTYPE'
16+
'_GO_PLATFORM_ID'
17+
'_GO_PLATFORM_VERSION_ID')
18+
local values=()
19+
local varname
20+
local result=()
21+
22+
for varname in "${varnames[@]}"; do
23+
values+=("${!varname}")
24+
done
25+
26+
@go.pad_items 'varnames' "${varnames[@]/%/:}"
27+
@go.zip_items 'varnames' 'values' ' ' result
28+
printf '%s\n' "${result[@]}"
29+
}
30+
31+
_@go.goinfo "$@"

tests/goinfo.bats

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#! /usr/bin/env bats
2+
3+
load environment
4+
5+
setup() {
6+
test_filter
7+
@go.create_test_go_script '@go "$@"'
8+
export __GO_ETC_OS_RELEASE="$BATS_TEST_ROOTDIR/os-release"
9+
}
10+
11+
teardown() {
12+
@go.remove_test_go_rootdir
13+
}
14+
15+
@test "$SUITE: emit version information about framework, Bash, and OS" {
16+
# Use simulated /etc/os-release to prevent computation via uname or sw_vers.
17+
mkdir -p "$BATS_TEST_ROOTDIR"
18+
printf '%s\n' \
19+
'ID=foobar' \
20+
'VERSION_ID=666' >"$__GO_ETC_OS_RELEASE"
21+
22+
run "$TEST_GO_SCRIPT" 'goinfo'
23+
assert_success
24+
assert_lines_equal \
25+
"_GO_CORE_VERSION: $_GO_CORE_VERSION" \
26+
"BASH_VERSION: $BASH_VERSION" \
27+
"OSTYPE: $OSTYPE" \
28+
'_GO_PLATFORM_ID: foobar' \
29+
'_GO_PLATFORM_VERSION_ID: 666'
30+
}

tests/platform.bats

Lines changed: 50 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,25 @@ setup() {
1212
' printf "%s=\"%s\"\n" "$var" "${!var}"' \
1313
'done'
1414
export __GO_ETC_OS_RELEASE="$BATS_TEST_ROOTDIR/os-release"
15+
16+
stub_program_in_path 'sw_vers' \
17+
'if [[ "$*" == "-productVersion" ]]; then' \
18+
' printf "$TEST_MACOS_VERSION\n"' \
19+
'fi'
20+
21+
stub_program_in_path 'uname' \
22+
'if [[ "$*" == "-r" ]]; then' \
23+
' printf "$TEST_UNAME_VERSION\n"' \
24+
'fi'
25+
26+
stub_program_in_path 'git' \
27+
'if [[ "$*" == "--version" ]]; then' \
28+
' printf "git version %s\n" "$TEST_GIT_VERSION"' \
29+
'fi'
1530
}
1631

1732
teardown() {
33+
restore_programs_in_path 'git' 'uname' 'sw_vers'
1834
@go.remove_test_go_rootdir
1935
}
2036

@@ -38,29 +54,46 @@ teardown() {
3854
'_GO_PLATFORM_VERSION_ID="666"'
3955
}
4056

41-
@test "$SUITE: set _GO_PLATFORM_ID from OSTYPE" {
42-
OSTYPE='foobar' run "$TEST_GO_SCRIPT"
43-
assert_success '_GO_PLATFORM_ID="foobar"'
57+
@test "$SUITE: set _GO_PLATFORM_{ID,VERSION_ID} from OSTYPE, uname -r" {
58+
OSTYPE='foobar' TEST_UNAME_VERSION='3.27' run "$TEST_GO_SCRIPT"
59+
assert_success
60+
assert_lines_equal \
61+
'_GO_PLATFORM_ID="foobar"' \
62+
'_GO_PLATFORM_VERSION_ID="3.27"'
4463
}
4564

46-
@test "$SUITE: set _GO_PLATFORM_ID to macos from OSTYPE" {
47-
OSTYPE='darwin16' run "$TEST_GO_SCRIPT"
48-
assert_success '_GO_PLATFORM_ID="macos"'
65+
@test "$SUITE: macos _GO_PLATFORM_{ID,VERSION_ID} from OSTYPE, sw_vers" {
66+
OSTYPE='darwin16.3.0' TEST_UNAME_VERSION='17.0.0' \
67+
TEST_MACOS_VERSION='10.13' run "$TEST_GO_SCRIPT"
68+
assert_success
69+
assert_lines_equal \
70+
'_GO_PLATFORM_ID="macos"' \
71+
'_GO_PLATFORM_VERSION_ID="10.13"'
4972
}
5073

51-
@test "$SUITE: set _GO_PLATFORM_ID to freebsd from OSTYPE" {
52-
OSTYPE='freebsd11.0' run "$TEST_GO_SCRIPT"
53-
assert_success '_GO_PLATFORM_ID="freebsd"'
74+
@test "$SUITE: freebsd _GO_PLATFORM_{ID,VERSION_ID} from OSTYPE, uname -r" {
75+
OSTYPE='freebsd11.0' TEST_UNAME_VERSION='11.1-RELEASE-p1' \
76+
run "$TEST_GO_SCRIPT"
77+
assert_success
78+
assert_lines_equal \
79+
'_GO_PLATFORM_ID="freebsd"' \
80+
'_GO_PLATFORM_VERSION_ID="11.1-RELEASE-p1"'
5481
}
5582

56-
@test "$SUITE: set _GO_PLATFORM_ID to msys from OSTYPE" {
57-
stub_program_in_path 'git' 'printf "%s\n" "git version 2.13.0"'
58-
OSTYPE='msys' run "$TEST_GO_SCRIPT"
59-
assert_success '_GO_PLATFORM_ID="msys"'
83+
@test "$SUITE: msys _GO_PLATFORM_{ID,VERSION_ID} from OSTYPE, uname -r" {
84+
OSTYPE='msys' TEST_UNAME_VERSION='2.9.0(0.318/5/3)' \
85+
TEST_GIT_VERSION='2.14.2' run "$TEST_GO_SCRIPT"
86+
assert_success
87+
assert_lines_equal \
88+
'_GO_PLATFORM_ID="msys"' \
89+
'_GO_PLATFORM_VERSION_ID="2.9.0(0.318/5/3)"'
6090
}
6191

62-
@test "$SUITE: set _GO_PLATFORM_ID to msys-git from OSTYPE and git --version" {
63-
stub_program_in_path 'git' 'printf "%s\n" "git version 2.13.0.windows.1"'
64-
OSTYPE='msys' run "$TEST_GO_SCRIPT"
65-
assert_success '_GO_PLATFORM_ID="msys-git"'
92+
@test "$SUITE: msys-git _GO_PLATFORM_* from OSTYPE, git --version, uname -r" {
93+
OSTYPE='msys' TEST_UNAME_VERSION='2.8.0(0.310/5/3)' \
94+
TEST_GIT_VERSION='git version 2.13.0.windows.1' run "$TEST_GO_SCRIPT"
95+
assert_success
96+
assert_lines_equal \
97+
'_GO_PLATFORM_ID="msys-git"' \
98+
'_GO_PLATFORM_VERSION_ID="2.8.0(0.310/5/3)"'
6699
}

0 commit comments

Comments
 (0)