Skip to content

Conversation

@mohammedahmed18
Copy link
Contributor

@mohammedahmed18 mohammedahmed18 commented Jul 1, 2025

User description

  • support single quotes, double quotes
  • ignore lines starting with #

PR Type

Enhancement, Tests


Description

  • Update export regex to ignore commented lines

  • Support single and double quotes in export

  • Add test for single-quoted API key

  • Add test for commented-out export returns None


Changes walkthrough 📝

Relevant files
Enhancement
shell_utils.py
Improve shell export regex                                                             

codeflash/code_utils/shell_utils.py

  • Modified SHELL_RC_EXPORT_PATTERN regex
  • Added negative lookahead to skip commented lines
  • Adjusted quote handling to accept single quotes
  • +1/-1     
    Tests
    test_shell_utils.py
    Add tests for shell regex enhancements                                     

    tests/test_shell_utils.py

  • Added test for single-quoted API key
  • Added test for ignored commented export
  • Ensured file open encoding remains utf8
  • +10/-0   

    Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • @github-actions
    Copy link

    github-actions bot commented Jul 1, 2025

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Regex Regression

    The updated pattern requires a closing quote even when no quotes are used, so unquoted API key exports will no longer match.

    SHELL_RC_EXPORT_PATTERN = re.compile(r'^(?!#)export CODEFLASH_API_KEY=[\'"]?(cf-[^\s"]+)[\'"]$', re.MULTILINE)
    Whitespace Handling

    The regex does not allow spaces around the = or before/after the export statement, which may fail for valid but differently formatted lines.

    SHELL_RC_EXPORT_PATTERN = re.compile(r'^(?!#)export CODEFLASH_API_KEY=[\'"]?(cf-[^\s"]+)[\'"]$', re.MULTILINE)

    @github-actions
    Copy link

    github-actions bot commented Jul 1, 2025

    PR Code Suggestions ✨

    No code suggestions found for the PR.

    @mohammedahmed18 mohammedahmed18 enabled auto-merge July 1, 2025 17:39
    @mohammedahmed18 mohammedahmed18 merged commit 9760a51 into main Jul 1, 2025
    17 checks passed
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    2 participants