Skip to content

Conversation

@Francesco146
Copy link

No description provided.

Copilot AI review requested due to automatic review settings December 20, 2025 08:00
Copy link
Contributor

Copilot AI left a 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.

Comment on lines +40 to +50
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"
Copy link

Copilot AI Dec 20, 2025

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.

Copilot uses AI. Check for mistakes.
# Convert to lowercase and split into words
set clean_name (echo $description | string lower | sed 's/[^a-z0-9]/ /g')

# Filter words
Copy link

Copilot AI Dec 20, 2025

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.

Suggested change
# Filter words
# Filter words: remove stop words and words shorter than 3 chars (unless they're uppercase acronyms in original)

Copilot uses AI. Check for mistakes.
exit 1
end

# Function to find the repository root
Copy link

Copilot AI Dec 20, 2025

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.

Suggested change
# Function to find the repository root
# Function to find the repository root by searching for existing project markers

Copilot uses AI. Check for mistakes.
Comment on lines +192 to +193
else if echo $description | string match -q "*"(string upper $word)"*"
# Keep short words if they appear as uppercase in original
Copy link

Copilot AI Dec 20, 2025

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
function check_existing_branches
set specs_dir $argv[1]

# Fetch all remotes
Copy link

Copilot AI Dec 20, 2025

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.

Suggested change
# Fetch all remotes
# Fetch all remotes to get latest branch info (suppress errors if no remotes)

Copilot uses AI. Check for mistakes.
end

# Force base-10 interpretation
set FEATURE_NUM (printf "%03d" (math $BRANCH_NUMBER + 0))
Copy link

Copilot AI Dec 20, 2025

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.

Copilot uses AI. Check for mistakes.
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
Copy link

Copilot AI Dec 20, 2025

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.

Suggested change
# GitHub enforces a 244-byte limit on branch names
# GitHub enforces a 244-byte limit on branch names
# Validate and truncate if necessary

Copilot uses AI. Check for mistakes.
echo $name | string lower | sed 's/[^a-z0-9]/-/g' | sed 's/-\+/-/g' | sed 's/^-//' | sed 's/-$//'
end

# Resolve repository root
Copy link

Copilot AI Dec 20, 2025

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.

Suggested change
# 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.

Copilot uses AI. Check for mistakes.
end
end

# Force base-10 interpretation
Copy link

Copilot AI Dec 20, 2025

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.

Suggested change
# Force base-10 interpretation
# Force base-10 interpretation to prevent octal conversion (e.g., 010 → 8 in octal, but should be 10 in decimal)

Copilot uses AI. Check for mistakes.
Comment on lines +220 to +222
# Fallback to original logic
set cleaned (clean_branch_name $description)
echo $cleaned | string split '-' | string match -v '' | head -3 | string join '-'
Copy link

Copilot AI Dec 20, 2025

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.

Suggested change
# 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/-$//'

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant