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

New Practice: Gitignore practice for Go lang #407

Open
prokopsimek opened this issue Sep 30, 2020 · 10 comments
Open

New Practice: Gitignore practice for Go lang #407

prokopsimek opened this issue Sep 30, 2020 · 10 comments

Comments

@prokopsimek
Copy link
Member

New Practice Proposal

Create a new practice that checks correctly set .gitignore for Go lang.

@prokopsimek prokopsimek self-assigned this Sep 30, 2020
@prokopsimek prokopsimek removed their assignment Sep 30, 2020
@K-Kumar-01
Copy link
Contributor

hello @prokopsimek Could you tell me a more about this issue. Any suitable links for this which can help me get the insight.

@adelkahomolova
Copy link
Contributor

Hi, @K-Kumar-01 . There exists the same practice for JavaScript. Check JsGitignoreCorrectlySetPractice.
It should be almost the same, just with specifications for GO lang. It should check if the programmer has his .gitignore in the GO lang project set correctly.
Is it clearer now? :)

@K-Kumar-01
Copy link
Contributor

Thanks @adelkahomolova for the explanation. I will see to the link and let you know about this as soon as possible

@K-Kumar-01
Copy link
Contributor

K-Kumar-01 commented Oct 19, 2020

Hello @adelkahomolova
I do not know much about Go and used this link for creating the file.
I made the dollowing changes in code

//node_modules
const binaryFilesRegex = parsedGitignore.find((value: string) => /exe$|exe~$|dll$|so$|dylib$|test$/.test(value));
// misc
const coverageRegex = parsedGitignore.find((value: string) => /out$/.test(value));
const dependencyRegex = parsedGitignore.find((value: string) => /vendor/.test(value));

I was not able to understand this part so i didnt change it.

const fixes = [
      binaryFilesRegex ? undefined : '/node_modules',
      coverageRegex ? undefined : '/coverage',
      dependencyRegex ? undefined : '*.log',
    ]

could you please tell me if my changes were correct and what i had to do in the fixes one.

@adelkahomolova
Copy link
Contributor

Hi, @K-Kumar-01 , the source should be fine I guess.
The fix() method is used for automated fix. So if it doesn't find regex node_modules it adds the string /node_modules in users' .gitignore. Same with /coverage and *-log. You should do the same for Go. So if there is no exe$, you should add it to the .gitignore - means it should be in the const fixes = []

Also your regexes should include the dots. So the first one should be .exe$|.exe~$|.dll$|.so$|.dylib$|.test$

Did I answer your questions?

@K-Kumar-01
Copy link
Contributor

@adelkahomolova Yes i had many doubts cleared. I will send the code once again when i have made the changes. Thanks for the clarfiication.

@K-Kumar-01
Copy link
Contributor

@adelkahomolova

const binaryFilesRegex = this.parsedGitignore.find((value: string) =>
      /.exe$|.exe~$|.dll$|.so$|.dylib$|.test$/.test(value),
    );
    // misc
    const coverageRegex = this.parsedGitignore.find((value: string) =>
      /.out$/.test(value),
    );
    const dependencyRegex = this.parsedGitignore.find((value: string) =>
      /vendor/.test(value),
    );
    const fixes = [
      binaryFilesRegex ? undefined : '.exe\n.exe~\n.dll\n.so\n.dylib\n.test\n',
      coverageRegex ? undefined : '.out',
      dependencyRegex ? undefined : 'vendor/',
    ]

So i made these. There is only one thing here that if in the regex only one file is also present then all others won't be included int the fix. So should i change the regex or will this work?

@K-Kumar-01 K-Kumar-01 mentioned this issue Oct 22, 2020
9 tasks
@adelkahomolova
Copy link
Contributor

Sorry, I missed that problem earlier. You shouldn't check the ignored files in one regex as you do in binaryFilesRegex. You should check every file separately, so you can fix only the ones the user doesn't ignore. @K-Kumar-01

@K-Kumar-01
Copy link
Contributor

@adelkahomolova
I edited the regex files. The PR was made. Please let me if it requires any fixes.

@K-Kumar-01
Copy link
Contributor

@adelkahomolova
All the changes that you requested were made in the latest PR.
Let me know if any changes are required.

@prokopsimek prokopsimek removed the Hacktoberfest https://hacktoberfest.digitalocean.com label Nov 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants