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

Recipe for .gitignore update #532

Open
jonesbusy opened this issue Dec 29, 2024 · 9 comments
Open

Recipe for .gitignore update #532

jonesbusy opened this issue Dec 29, 2024 · 9 comments
Labels
good first issue Good for newcomers

Comments

@jonesbusy
Copy link
Collaborator

jonesbusy commented Dec 29, 2024

What feature do you want to see added?

Right now the .gitignore is just added when missing.

We need some logic to merge with entries from archetype

Upstream changes

None

Are you interested in contributing this feature?

No response

@jonesbusy jonesbusy added the good first issue Good for newcomers label Dec 30, 2024
@nagu165
Copy link
Contributor

nagu165 commented Jan 2, 2025

Hello sir,
If i may ask for some more context regarding this

What i understood : Creating an openrewrite recipe to merge the entries from a .gitignore file in an archetype with an existing .gitignore file
Am i right?

@jonesbusy
Copy link
Collaborator Author

Yes if the file is missing it's created (already the case).

But if the file already exist entries must be merged with the .gitignore entries from archetype to ensure user defined entries are not erased.

It's possible that JGit provide some utilities to know if some entries are overlapping.

@jonesbusy
Copy link
Collaborator Author

@nagu165
Copy link
Contributor

nagu165 commented Jan 2, 2025

Understood sir, I'm assuming it's similar to what i am working on with pr#560 so can i work on this simultaneously along with it.

Thank you.

@nagu165
Copy link
Contributor

nagu165 commented Jan 4, 2025

Yes if the file is missing it's created (already the case).

But if the file already exist entries must be merged with the .gitignore entries from archetype to ensure user defined entries are not erased.

It's possible that JGit provide some utilities to know if some entries are overlapping.

https://archive.eclipse.org/jgit/site/6.3.0.202209071007-r/org.eclipse.jgit/apidocs/org.eclipse.jgit/org/eclipse/jgit/ignore/FastIgnoreRule.html
Is this the JGit utility you were referring to? I think this might work.

@jonesbusy
Copy link
Collaborator Author

Yea : https://github.com/eclipse-jgit/jgit/blob/master/org.eclipse.jgit/src/org/eclipse/jgit/ignore/FastIgnoreRule.java

(Just note that we are on latest version of JGit)

@nagu165
Copy link
Contributor

nagu165 commented Jan 5, 2025

Hello sir,
Sorry if i am wasting your time.
I've been searching for a way to write the tests for merging gitignore files but couldn't find any solid resource on it.(I did find some ways but i'm not very confident that they are correct)
Could you please share any resource that might help me.

Thank you.

@jonesbusy
Copy link
Collaborator Author

Please come with a proposal. I don't have the answer to the question

@nagu165
Copy link
Contributor

nagu165 commented Jan 6, 2025

I tried having 3 text blocks (1 for the gitignore that already exists, 1 for archetype file, 1 the expected result after merging ) will this work?
May i open a pr for it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants