JonBoyleCoding / gitignore-template

Download the gitignore template from github.com/github/gitignore into the current directory.
MIT License
0 stars 0 forks source link

Sweep: Add ability to pull gitignores from Global and Community #15

Open JonBoyleCoding opened 1 year ago

JonBoyleCoding commented 1 year ago

The https://github.com/github/gitignore repository also has sets of files within Global and Community. Add the ability to search these as well as the root of the repository (as is the case now)

Checklist - [X] `gitignore_template/typer_main.py` > • Add a new argument to the `typer_main` function to allow the user to specify the directory to search in. The argument should be of type str and default to the root directory. Update the help text of the argument to inform the user that they can specify the 'Global' or 'Community' directories. > • Update the call to the `get_potential_filenames` function in the `typer_main` function to pass the new argument. > • Update the `get_potential_filenames` function to accept the new argument and use it to fetch .gitignore files from the specified directory. This can be done by passing the argument to the `get_contents` method of the `Repository` object. - [X] `tests/test_typer_main.py` > • Update any tests that call the `get_potential_filenames` and `typer_main` functions to pass the new argument. Ensure that the tests cover all possible values of the argument.
sweep-ai[bot] commented 1 year ago

Here's the PR! https://github.com/JonBoyleCoding/gitignore-template/pull/17.

⚡ Sweep Free Trial: I used GPT-4 to create this ticket. You have 4 GPT-4 tickets left for the month and 1 for the day. For more GPT-4 tickets, visit our payment portal. To retrigger Sweep, edit the issue.


Step 1: 🔍 Code Search

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I looked at (click to expand). If some file is missing from here, you can mention the path in the ticket description. https://github.com/JonBoyleCoding/gitignore-template/blob/c1877c781baf615c02ead3a64c40ca48e89c4a96/gitignore_template/typer_main.py#L1-L144 https://github.com/JonBoyleCoding/gitignore-template/blob/c1877c781baf615c02ead3a64c40ca48e89c4a96/gitignore_template/__init__.py#L1-L0 https://github.com/JonBoyleCoding/gitignore-template/blob/c1877c781baf615c02ead3a64c40ca48e89c4a96/pyproject.toml#L1-L27 https://github.com/JonBoyleCoding/gitignore-template/blob/c1877c781baf615c02ead3a64c40ca48e89c4a96/gitignore_template/typer_main.py#L76-L144 https://github.com/JonBoyleCoding/gitignore-template/blob/c1877c781baf615c02ead3a64c40ca48e89c4a96/CHANGES.md#L1-L31

I also found the following external resources that might be helpful:

Summaries of links found in the content:

https://github.com/github/gitignore:

The page is the GitHub repository for github/gitignore, which is a collection of useful .gitignore templates. The repository contains templates organized into three folders: root, Global, and Community. The root folder contains templates for popular programming languages and technologies. The Global folder contains templates for various editors, tools, and operating systems that can be used in different situations. The Community folder contains specialized templates for other popular languages, tools, and projects that don't currently belong in the mainstream templates. The page also provides guidelines for contributing to the repository, including providing links to documentation supporting the change, explaining the reason for the change, and considering the scope of the change. It also mentions versioned templates and specialized templates. The page includes code snippets showing the folder structure and examples of template files.


Step 2: 🧐 Snippet Analysis

From looking through the relevant snippets, I decided to make the following modifications:

File Path Proposed Changes
gitignore_template/typer_main.py Modify gitignore_template/typer_main.py with contents:
• Add a new argument to the typer_main function to allow the user to specify the directory to search in. The argument should be of type str and default to the root directory. Update the help text of the argument to inform the user that they can specify the 'Global' or 'Community' directories.
• Update the call to the get_potential_filenames function in the typer_main function to pass the new argument.
• Update the get_potential_filenames function to accept the new argument and use it to fetch .gitignore files from the specified directory. This can be done by passing the argument to the get_contents method of the Repository object.
tests/test_typer_main.py Modify tests/test_typer_main.py with contents:
• Update any tests that call the get_potential_filenames and typer_main functions to pass the new argument. Ensure that the tests cover all possible values of the argument.

Step 3: 📝 Planning

I have created a plan for writing the pull request. I am now working my plan and coding the required changes to address this issue. Here is the planned pull request:

Add ability to search in 'Global' and 'Community' directories sweep/search-global-community

Description

This PR adds the ability to search for .gitignore templates in the 'Global' and 'Community' directories of the github/gitignore repository. Currently, the gitignore-template tool only searches in the root directory. This enhancement allows users to access a wider range of templates for different editors, tools, and operating systems.

Summary of Changes

  • Updated the get_potential_filenames function to fetch .gitignore files from the 'Global' and 'Community' directories in addition to the root directory. This was achieved by using the get_contents method of the Repository object with the appropriate path.
  • Updated the typer_main function to allow the user to specify the directory to search in. A new argument directory was added to the function, which defaults to the root directory. The help text of the argument was updated to inform the user that they can specify the 'Global' or 'Community' directories.
  • Updated the user interface to inform the user that they can now search in the 'Global' and 'Community' directories.
  • Updated any function calls and tests that use the get_potential_filenames and typer_main functions to accommodate these changes.

Please review and merge this PR to enable users to access a wider range of .gitignore templates.


Step 4: ⌨️ Coding

File Instructions Progress Error logs
gitignore_template/typer_main.py Modify gitignore_template/typer_main.py with contents:
• Add a new argument to the typer_main function to allow the user to specify the directory to search in. The argument should be of type str and default to the root directory. Update the help text of the argument to inform the user that they can specify the 'Global' or 'Community' directories.
• Update the call to the get_potential_filenames function in the typer_main function to pass the new argument.
• Update the get_potential_filenames function to accept the new argument and use it to fetch .gitignore files from the specified directory. This can be done by passing the argument to the get_contents method of the Repository object.
✅ Commit 83b5fe8 No errors.
tests/test_typer_main.py Modify tests/test_typer_main.py with contents:
• Update any tests that call the get_potential_filenames and typer_main functions to pass the new argument. Ensure that the tests cover all possible values of the argument.
✅ Commit 53adb55 No errors. I have finished coding the issue. I am now reviewing it for completeness.

Step 5: 🔁 Code Review

Here are my self-reviews of my changes at sweep/search-global-community.

Here is the 1st review

No changes required. The code changes in both gitignore_template/typer_main.py and tests/test_typer_main.py are correct and fully implemented. The addition of the directory argument to the functions typer_main and get_potential_filenames is well done, and the new tests test_get_potential_filenames_global and test_get_potential_filenames_community are correctly checking the new functionality. Good job!

I finished incorporating these changes.


🎉 Latest improvements to Sweep:


💡 To recreate the pull request edit the issue title or description. Join Our Discord