-
Notifications
You must be signed in to change notification settings - Fork 5k
feat(shell): add fish support to create-new-feature
#1361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds Fish shell support to the create-new-feature script, providing an alternative implementation for Fish shell users alongside the existing Bash version.
- Implements full feature creation workflow including argument parsing, branch name generation, and spec file setup
- Translates Bash script logic to Fish shell syntax while maintaining functional equivalence
- Supports JSON output mode, custom short names, and manual branch numbering
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| echo "Usage: create-new-feature.fish [--json] [--short-name <name>] [--number N] <feature_description>" | ||
| echo "" | ||
| echo "Options:" | ||
| echo " --json Output in JSON format" | ||
| echo " --short-name <name> Provide a custom short name (2-4 words) for the branch" | ||
| echo " --number N Specify branch number manually (overrides auto-detection)" | ||
| echo " --help, -h Show this help message" | ||
| echo "" | ||
| echo "Examples:" | ||
| echo " create-new-feature.fish 'Add user authentication system' --short-name 'user-auth'" | ||
| echo " create-new-feature.fish 'Implement OAuth2 integration for API' --number 5" |
Copilot
AI
Dec 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The help text uses a hardcoded script name instead of a variable. The bash version uses $0 to dynamically show the script name that was invoked, which is more flexible and accurate. This fish version should use something like (status --current-filename) or basename of it to match the bash behavior and show the actual invoked script name.
| # Convert to lowercase and split into words | ||
| set clean_name (echo $description | string lower | sed 's/[^a-z0-9]/ /g') | ||
|
|
||
| # Filter words |
Copilot
AI
Dec 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment differs from bash version. The bash version says "Filter words: remove stop words and words shorter than 3 chars (unless they're uppercase acronyms in original)" which is more descriptive. The fish version says "Filter words" followed by "Keep words that are NOT stop words AND (length >= 3 OR are potential acronyms)" in a later comment. Consider matching the bash version's comment style for consistency.
| # Filter words | |
| # Filter words: remove stop words and words shorter than 3 chars (unless they're uppercase acronyms in original) |
| exit 1 | ||
| end | ||
|
|
||
| # Function to find the repository root |
Copilot
AI
Dec 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing explanatory comment. The bash version has "Function to find the repository root by searching for existing project markers" which is more descriptive than just "Function to find the repository root". The additional context about "searching for existing project markers" helps explain what the function does. Consider adding this for better documentation.
| # Function to find the repository root | |
| # Function to find the repository root by searching for existing project markers |
| else if echo $description | string match -q "*"(string upper $word)"*" | ||
| # Keep short words if they appear as uppercase in original |
Copilot
AI
Dec 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The acronym detection logic differs from the bash version. The bash version checks if the word appears as uppercase in the original description using grep -q "\b${word^^}\b" with word boundaries. The fish version uses string match -q "*"(string upper $word)"*" which performs a substring match and could produce false positives. For example, if the word "id" appears anywhere in "valid", it would match. Consider using a more precise matching approach.
| else if echo $description | string match -q "*"(string upper $word)"*" | |
| # Keep short words if they appear as uppercase in original | |
| else if echo $description | grep -q -w (string upper $word) | |
| # Keep short words if they appear as uppercase in original as a whole word |
| function check_existing_branches | ||
| set specs_dir $argv[1] | ||
|
|
||
| # Fetch all remotes |
Copilot
AI
Dec 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing comment about remote fetching. The bash version has "Fetch all remotes to get latest branch info (suppress errors if no remotes)" which explains both the action and the error suppression strategy. The fish version lacks this comment. Consider adding it for better documentation.
| # Fetch all remotes | |
| # Fetch all remotes to get latest branch info (suppress errors if no remotes) |
| end | ||
|
|
||
| # Force base-10 interpretation | ||
| set FEATURE_NUM (printf "%03d" (math $BRANCH_NUMBER + 0)) |
Copilot
AI
Dec 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing base-10 interpretation prefix. The bash version uses $((10#$BRANCH_NUMBER)) to force base-10 interpretation and prevent octal conversion (e.g., "010" being interpreted as octal 8 instead of decimal 10). The fish version only uses (math $BRANCH_NUMBER + 0) which may not handle this edge case correctly. This could lead to incorrect branch numbering when branch numbers like 008, 009, 010, etc. are provided.
| set FEATURE_NUM (printf "%03d" (math $BRANCH_NUMBER + 0)) | ||
| set BRANCH_NAME "$FEATURE_NUM-$BRANCH_SUFFIX" | ||
|
|
||
| # GitHub enforces a 244-byte limit on branch names |
Copilot
AI
Dec 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing comment for branch name validation section. The bash version includes a comment "Validate and truncate if necessary" after the main comment about GitHub's 244-byte limit. This helps clarify the purpose of the following code block. Consider adding this comment for consistency and clarity.
| # GitHub enforces a 244-byte limit on branch names | |
| # GitHub enforces a 244-byte limit on branch names | |
| # Validate and truncate if necessary |
| echo $name | string lower | sed 's/[^a-z0-9]/-/g' | sed 's/-\+/-/g' | sed 's/^-//' | sed 's/-$//' | ||
| end | ||
|
|
||
| # Resolve repository root |
Copilot
AI
Dec 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing detailed comment about repository root detection. The bash version includes an explanatory comment: "Resolve repository root. Prefer git information when available, but fall back to searching for repository markers so the workflow still functions in repositories that were initialised with --no-git." This provides important context about the design decision. Consider adding this comment for better maintainability.
| # Resolve repository root | |
| # Resolve repository root. Prefer git information when available, but fall back | |
| # to searching for repository markers so the workflow still functions in | |
| # repositories that were initialised with --no-git. |
| end | ||
| end | ||
|
|
||
| # Force base-10 interpretation |
Copilot
AI
Dec 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent comment format. The bash version has a more detailed comment explaining "Force base-10 interpretation to prevent octal conversion (e.g., 010 → 8 in octal, but should be 10 in decimal)". This fish version only says "Force base-10 interpretation" without the helpful explanation. For maintainability and clarity, consider adding the full explanation as in the bash version.
| # Force base-10 interpretation | |
| # Force base-10 interpretation to prevent octal conversion (e.g., 010 → 8 in octal, but should be 10 in decimal) |
| # Fallback to original logic | ||
| set cleaned (clean_branch_name $description) | ||
| echo $cleaned | string split '-' | string match -v '' | head -3 | string join '-' |
Copilot
AI
Dec 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fallback branch name generation logic differs from the bash version. The bash version uses tr '\n' '-' | sed 's/-$//' to join words and remove trailing hyphens, while the fish version uses string join '-'. While both achieve similar results, the bash version explicitly processes the cleaned output through tr '-' '\n' | grep -v '^$' | head -3 to split, filter empty strings, take first 3, then rejoin. The fish version uses string split '-' | string match -v '' | head -3 | string join '-' which should work equivalently. However, verify this produces identical results in edge cases.
| # Fallback to original logic | |
| set cleaned (clean_branch_name $description) | |
| echo $cleaned | string split '-' | string match -v '' | head -3 | string join '-' | |
| # Fallback to original logic (match bash implementation) | |
| set cleaned (clean_branch_name $description) | |
| echo $cleaned | tr '-' '\n' | grep -v '^$' | head -3 | tr '\n' '-' | sed 's/-$//' |
No description provided.