Skip to content

Conversation

@rtoohil
Copy link

@rtoohil rtoohil commented Dec 1, 2025

As mentioned in #33, if you have one of the "key" compose file names, up and down will choose that file, even if you've provided a file via the -f flag. This changes the logic to choose and handle the -f flag appropriately.

With Swift not being my primary language, I've worked with Claude Code to build this PR.

@Mcrich23
Copy link
Owner

Mcrich23 commented Dec 1, 2025

Thank you so much! I appreciate your disclosure of using claude and I will review it when I have a chance

@rtoohil
Copy link
Author

rtoohil commented Dec 1, 2025

I'm really excited about the possibilities here (for compose, which I think is sorely needed for container), so I thought I'd try to contribute. If it turns out that the work Claude is doing (with some guidance/assistance from me) is not what it needs to be, let me know, and I can do a few more turns with a fine toothed comb.

Copy link

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 fixes the issue where the -f flag was being ignored when one of the default compose file names existed in the current directory. The changes ensure that when a user explicitly specifies a compose file via the -f flag, that file takes precedence over the automatic file discovery.

Key Changes

  • Changed composeFilename from a non-optional String with a default value to an optional String (nil by default)
  • Modified the file discovery logic to only search for default filenames when -f is not provided
  • Added support for absolute paths (starting with / or ~) in the -f flag

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
Sources/Container-Compose/Commands/ComposeUp.swift Updated to respect the -f flag and handle absolute paths
Sources/Container-Compose/Commands/ComposeDown.swift Updated to respect the -f flag and handle absolute paths

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 78 to 80
if composeFilename == nil {
composeFilename = "compose.yml"
}
Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fallback assignment is redundant since line 49 already handles the nil case with composeFilename ?? \"compose.yml\". The composePath computed property will always default to "compose.yml" if composeFilename is nil, making this assignment unnecessary.

Suggested change
if composeFilename == nil {
composeFilename = "compose.yml"
}
// No need to assign composeFilename = "compose.yml" here; composePath already handles the nil case.

Copilot uses AI. Check for mistakes.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot is correct. this final if composeFilename == nil { is unnecessary. Please delete the if statement and do not leave the comment that copilot is suggesting.

Comment on lines 78 to 80
if composeFilename == nil {
composeFilename = "compose.yml"
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot is correct. this final if composeFilename == nil { is unnecessary. Please delete the if statement and do not leave the comment that copilot is suggesting.

}
}
// If no file was found, default to compose.yml (will fail later with proper error)
if composeFilename == nil {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was correct. this final if composeFilename == nil { is unnecessary. Please delete the if statement and do not leave the comment that copilot is suggesting.

@Mcrich23 Mcrich23 self-assigned this Dec 3, 2025
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.

2 participants