Summary
The gh-pages library fails when deploying if a file in the gh-pages branch of the remote repository has a name starting with a - (dash). This happens because git rm interprets such filenames as options rather than file paths.
Steps to Reproduce
- Clone the example repository:
git clone https://github.com/sherlockdoyle/gh-pages-bug-demo
- Navigate into the repository:
- Install dependencies:
- Deploy using
gh-pages:
Expected Behavior
The gh-pages command should correctly handle files with names starting with a - (dash) and deploy successfully.
Actual Behavior
The deployment fails with the following error:
ProcessError: error: unknown switch `t'
usage: git rm [-f | --force] [-n] [-r] [--cached] [--ignore-unmatch]
[--quiet] [--pathspec-from-file=<file> [--pathspec-file-nul]]
[--] [<pathspec>...]
The file -test.js in the gh-pages branch causes git rm to interpret -t as an invalid option.
Root Cause
The issue arises because git rm is called without properly escaping filenames. Files starting with a - are treated as command-line options by Git instead of file paths.
Suggested Fix
Use -- to signal the end of command options in the git rm command. For example:
This ensures Git treats -test.js as a file name rather than an option.
Summary
The
gh-pageslibrary fails when deploying if a file in thegh-pagesbranch of the remote repository has a name starting with a-(dash). This happens becausegit rminterprets such filenames as options rather than file paths.Steps to Reproduce
gh-pages:Expected Behavior
The
gh-pagescommand should correctly handle files with names starting with a-(dash) and deploy successfully.Actual Behavior
The deployment fails with the following error:
The file
-test.jsin thegh-pagesbranch causesgit rmto interpret-tas an invalid option.Root Cause
The issue arises because
git rmis called without properly escaping filenames. Files starting with a-are treated as command-line options by Git instead of file paths.Suggested Fix
Use
--to signal the end of command options in thegit rmcommand. For example:This ensures Git treats
-test.jsas a file name rather than an option.