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

Request for support to ignore files or directories in patch-commit command #6565

Closed
1 task done
kirklin opened this issue May 19, 2023 · 6 comments · Fixed by #6596
Closed
1 task done

Request for support to ignore files or directories in patch-commit command #6565

kirklin opened this issue May 19, 2023 · 6 comments · Fixed by #6596

Comments

@kirklin
Copy link
Contributor

kirklin commented May 19, 2023

Describe the user story
As a developer, I often want to use the patch-commit command in pnpm to apply patches to my project, but I face difficulties in excluding specific files or directories from the patch commit process.

Describe the solution you'd like
I would like the patch-commit command in pnpm to support the ability to ignore certain files or directories during the patch commit process. This would allow me to have better control over the scope of my commits and avoid including unnecessary changes.

Describe the drawbacks of your solution
One potential drawback of implementing this feature is the increased complexity in managing and configuring the ignore functionality. It may require additional options or configuration files to specify the files or directories to be ignored. There could also be potential compatibility issues with existing workflows or tools that rely on the current behavior of the patch-commit command.

Describe alternatives you've considered
One alternative solution could be to manually modify the patch files generated by pnpm to remove the unwanted changes before committing. However, this approach is error-prone and time-consuming, especially when dealing with multiple patch files or complex patches. Another alternative could be to create separate branches or patches for different sets of files, but this would lead to a more fragmented version control history and make it harder to track and manage the patches effectively.

Overall, I believe that adding the ability to ignore files or directories in the patch-commit command would provide a more flexible and streamlined patching process within pnpm.

@zkochan
Copy link
Member

zkochan commented May 19, 2023

I don't understand this scenario. Why do you modify files if you don't want them to be in the patch?

@kirklin
Copy link
Contributor Author

kirklin commented May 20, 2023

I apologize for any confusion caused. Allow me to clarify the scenario.

In some cases, when working with patches, there may be certain files or directories that we do not want to include in the patch but are inadvertently included due to various factors. For example, when using an IDE like WebStorm to open the patched project, the IDE may generate certain files or directories (e.g., .idea) in the project's root directory. This can be frustrating because these files should not be part of the patch.

Similarly, when sharing the patched project through Git within a company, it is important to track and share the history of modifications. However, when executing the patch-commit command, the entire .git folder, including its contents, is included in the patch, which is not desirable.

The request to ignore specific files or directories in the patch-commit command aims to address these situations. By allowing users to specify which files or directories should be excluded from the patching process, we can have more control over the patch's content and ensure that only the intended changes are included.

I hope this clarifies the reasons behind the request for the ability to ignore files or directories in the patch-commit command. Please let me know if you have any further questions or concerns.

@zkochan
Copy link
Member

zkochan commented May 21, 2023

I see, makes sense. I think it would be best to ignore these files be default, if possible. We can ignore .git for sure. Not sure about the other ones.

@kirklin
Copy link
Contributor Author

kirklin commented May 21, 2023

I appreciate your understanding. It is indeed beneficial to have certain files, like the .git directory, ignored by default in the patching workflow to prevent the unintentional inclusion of sensitive or unnecessary files in the patch.

In addition to the default ignore list, it would be valuable to provide a configurable option for users to specify additional files or directories to ignore during the patching process. This would allow users to customize the ignore list according to their specific project needs and requirements.

By striking a balance between convenience and flexibility, we can provide a default ignore list that includes common files and directories, such as .git, while also empowering users to extend or modify the list as needed.

To achieve this, incorporating a configuration file, such as an .pnpmrc, or utilizing project-specific configuration files like pnpm.config.ts, would be an excellent approach. This centralized and project-specific configuration would enable users to define their own set of ignored files and directories, tailored to their project's unique circumstances. It offers scalability and accommodates diverse project setups and workflows.

With the support of a configuration file, users would have fine-grained control over which files and directories are excluded from the patching process. They can easily manage and adjust the ignore patterns within the configuration file, ensuring that the resulting patch commits accurately reflect their desired changes.

@kirklin
Copy link
Contributor Author

kirklin commented May 21, 2023

Maybe we can use the .gitignore syntax as a reference?
Including a reference to the .gitignore syntax would be beneficial in designing the ignore functionality for the patch-commit command. The .gitignore syntax is widely recognized and understood by developers, and leveraging its format would provide familiarity and consistency.

By adopting the .gitignore syntax, users can utilize patterns, wildcards, and other syntax elements commonly used in .gitignore files to specify files or directories they want to ignore during the patching process. This approach aligns with established practices and allows users to leverage their existing knowledge of .gitignore rules when configuring the ignore list for patch-commit.

Taking inspiration from the .gitignore syntax not only promotes consistency but also simplifies the learning curve for users who are already familiar with it. They can easily adapt and apply their knowledge to the ignore functionality of the patch-commit command.

@zkochan
Copy link
Member

zkochan commented May 21, 2023

We could utilize the the settings that are already present for telling pnpm which files to include, when packing the package.

  • the files field in package.json
  • the .npmignore file

zkochan added a commit that referenced this issue Jun 8, 2023
…tched package (#6596)

close #6565

---------

Co-authored-by: Zoltan Kochan <z@kochan.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants