Skip to content
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

feat: ignore .git generated by git worktree add #943

Merged
merged 2 commits into from
Apr 15, 2024

Conversation

yutotnh
Copy link
Contributor

@yutotnh yutotnh commented Mar 26, 2024

purpose

Add .git files to the exclusion list so that unwanted files are not included in the vsix package.

Since .git contains the full path to the original directory of the working tree, as shown below, we do not want to expose it to the outside world too much.

$ cat .git
gitdir: /home/user/dir/word-divider/.git/worktrees/word-driver-main

details

When I create a worktree using git worktree add, it creates a file called .git.

The current exclusion pattern only excludes the .git directory.

So if I run yarn vsce ls as in the following execution, it will include .git among the files to be included in the package.

$ yarn vsce ls
~~~~ omit ~~~~
 INFO  Detected presence of yarn.lock. Using 'yarn' instead of 'npm' (to override this pass '--no-yarn' on the command line).
.git                        # Contains .git files
CHANGELOG.md
dist/web/extension.js
dist/web/testSuiteIndex.js
docs/icon.png
LICENSE
package.json
package.nls.ja.json
package.nls.json
package.nls.zh-cn.json
package.nls.zh-tw.json
README.md
Done in 6.05s.

I created a package and looked at the contents, and sure enough, there was a git file in it.

$ tree -a word-divider-0.2.1
word-divider-0.2.1
├── [Content_Types].xml
├── extension
│   ├── .git                # Contains .git files
│   ├── CHANGELOG.md
│   ├── LICENSE.txt
│   ├── README.md
│   ├── dist
│   │   └── web
│   │       ├── extension.js
│   │       └── testSuiteIndex.js
│   ├── docs
│   │   └── icon.png
│   ├── package.json
│   ├── package.nls.ja.json
│   ├── package.nls.json
│   ├── package.nls.zh-cn.json
│   └── package.nls.zh-tw.json
└── extension.vsixmanifest

5 directories, 14 files

After modification

When I run yarn vsce ls, the .git file is not included.

$ yarn vsce ls
~~~~ omit ~~~~
 INFO  Detected presence of yarn.lock. Using 'yarn' instead of 'npm' (to override this pass '--no-yarn' on the command line).
CHANGELOG.md
dist/web/extension.js
dist/web/testSuiteIndex.js
docs/icon.png
LICENSE
package.json
package.nls.ja.json
package.nls.json
package.nls.zh-cn.json
package.nls.zh-tw.json
README.md
Done in 6.27s.

I checked the created package and it no longer contained a .git file.

$ tree -a word-divider-0.2.1
word-divider-0.2.1
├── [Content_Types].xml
├── extension
│   ├── CHANGELOG.md
│   ├── LICENSE.txt
│   ├── README.md
│   ├── dist
│   │   └── web
│   │       ├── extension.js
│   │       └── testSuiteIndex.js
│   ├── docs
│   │   └── icon.png
│   ├── package.json
│   ├── package.nls.ja.json
│   ├── package.nls.json
│   ├── package.nls.zh-cn.json
│   └── package.nls.zh-tw.json
└── extension.vsixmanifest

5 directories, 13 files

@benibenj benibenj self-requested a review April 13, 2024 09:14
@benibenj benibenj self-assigned this Apr 13, 2024
@benibenj benibenj added this to the April 2024 milestone Apr 13, 2024
@benibenj
Copy link
Contributor

Thanks for the PR

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.

5 participants