@@ -37,6 +37,8 @@ module Git
output = output.sub(/<\/refmeta>/, new_tags + "</refmeta>")
end
output
+ end
+ end
class AnnotateProcessor < Asciidoctor::Extensions::InlineMacroProcessor
def process(parent, target, attrs)
@@ -368,6 +368,15 @@ int cmd_main(int argc, const char **argv)
if (!stat(report_path.buf, &statbuf))
die("'%s' already exists", report_path.buf);
+ switch (safe_create_leading_directories(report_path.buf)) {
+ case SCLD_OK:
+ case SCLD_EXISTS:
+ break;
+ default:
+ die(_("could not create leading directories for '%s'"),
+ report_path.buf);
+ }
+
get_bug_template(&buffer);
get_header(&buffer, "System Info");
@@ -54,6 +54,7 @@ git-archive mainporcelain
git-bisect mainporcelain info
git-blame ancillaryinterrogators complete
git-branch mainporcelain history
+git-bugreport ancillaryinterrogators
git-bundle mainporcelain
git-cat-file plumbinginterrogators
git-check-attr purehelpers
@@ -10,7 +10,8 @@ EOF
# cat all regular files in Documentation/config
find Documentation/config -type f -exec cat {} \; |
# print the command name which matches the annotate-bugreport macro
-sed -n 's/^\(.*\) \+annotate:bugreport\[include\].* ::$/ "\1",/p' | sort
+sed -n 's/^\([^[:blank:]]*\)[[:blank:]]\{1,\}annotate:bugreport\[include\].* ::$/ "\1",/p' \
+ | sort
cat <<EOF
};
@@ -10,10 +10,7 @@ EOF
grep -h '^[a-zA-Z].*\..*::$' Documentation/*config.txt Documentation/config/*.txt |
sed '/deprecated/d; s/::$//; s/, */\n/g' |
sort |
- while read line
- do
- echo " \"$line\","
- done
+ sed 's/^.*$/ "&",/'
cat <<EOF
NULL,
};
@@ -8,9 +8,12 @@ test_description='git bugreport'
# information there; we can make sure all our headers were followed by some
# information to check if the command was successful.
HEADER_PATTERN="^\[.*\]$"
-check_all_headers_populated() {
- while read -r line; do
- if test "$(grep "$HEADER_PATTERN" "$line")"; then
+
+check_all_headers_populated () {
+ while read -r line
+ do
+ if test "$(grep "$HEADER_PATTERN" "$line")"
+ then
echo "$line"
read -r nextline
if test -z "$nextline"; then
@@ -21,29 +24,32 @@ check_all_headers_populated() {
}
test_expect_success 'creates a report with content in the right places' '
- git bugreport &&
- REPORT="$(ls git-bugreport-*)" &&
- check_all_headers_populated <$REPORT &&
- rm $REPORT
+ git bugreport -s check-headers &&
+ check_all_headers_populated <git-bugreport-check-headers.txt &&
+ test_when_finished rm git-bugreport-check-headers.txt
'
test_expect_success 'dies if file with same name as report already exists' '
- touch git-bugreport-duplicate.txt &&
+ >>git-bugreport-duplicate.txt &&
test_must_fail git bugreport --suffix duplicate &&
- rm git-bugreport-duplicate.txt
+ test_when_finished rm git-bugreport-duplicate.txt
'
test_expect_success '--output-directory puts the report in the provided dir' '
- mkdir foo/ &&
git bugreport -o foo/ &&
test_path_is_file foo/git-bugreport-* &&
- rm -fr foo/
+ test_when_finished rm -fr foo/
'
test_expect_success 'incorrect arguments abort with usage' '
test_must_fail git bugreport --false 2>output &&
- grep usage output &&
+ test_i18ngrep usage output &&
test_path_is_missing git-bugreport-*
'
+test_expect_success 'runs outside of a git dir' '
+ nongit git bugreport &&
+ test_when_finished rm non-repo/git-bugreport-*
+'
+
test_done