Skip to content

Generator strips square brackets from code before Argbash directives #208

Description

@native-api

Passing https://github.com/native-api/git-scripts/blob/1bbc9e6bad9a12debcc979e3c3cb5c63aca8200f/bin/git-prw through https://argbash.dev/generate results in it breaking an action option's worker function (which has to be before the Argbash script for parse_commandline to find it) by stripping all square brackets from it:

 bin/git-prw | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/bin/git-prw b/bin/git-prw
index 8b45be1..9ef7e8c 100755
--- a/bin/git-prw
+++ b/bin/git-prw
@@ -36,16 +36,16 @@ EOF
 
 prune() {
   local IFS=$'\n'
-  local -a unchecked_pr_branches=($(git branch --list pr/\* | grep -Ex '^  pr/[0-9]+' | cut -c 3-))
-  (( "${#unchecked_pr_branches[@]}" )) && git branch -D "${unchecked_pr_branches[@]}"
-  
-  local -a used_remotes=($(git config --local --get-regexp 'branch\.[^.]+\.remote' | cut -d ' ' -f 2-))
-  
-  local -a pr_remotes=($(git remote | grep -Ex '.*-fork-for-pr-[0-9]+'))
-  local -a unused_pr_remotes=($(printf '%s\n' "${pr_remotes[@]}" | grep -vxFf <(print '%s\n' "${used_remotes[@]}")))
-  
+  local -a unchecked_pr_branches=($(git branch --list pr/\* | grep -Ex '^  pr/0-9+' | cut -c 3-))
+  (( "${#unchecked_pr_branches@}" )) && git branch -D "${unchecked_pr_branches@}"
+
+  local -a used_remotes=($(git config --local --get-regexp 'branch\.^.+\.remote' | cut -d ' ' -f 2-))
+
+  local -a pr_remotes=($(git remote | grep -Ex '.*-fork-for-pr-0-9+'))
+  local -a unused_pr_remotes=($(printf '%s\n' "${pr_remotes@}" | grep -vxFf <(print '%s\n' "${used_remotes@}")))
+
   local r
-  for r in "${unused_pr_remotes[@]}"
+  for r in "${unused_pr_remotes@}"
   do
     git remote remove "$r"
     echo "Removed remote $r"

The expected behavior is for the generator to pass through any code that comes before the Argbash directives in comments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions