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

Automatically create ".stignore" file if does not exist #1169

Merged
merged 4 commits into from
Nov 19, 2020
Merged

Conversation

pchico83
Copy link
Contributor

Proposed changes

  • Also, check if .git is defined in the .stignore file

@derek
Copy link

derek bot commented Nov 17, 2020

Thank you for your contribution. I've just checked and your commit doesn't appear to be signed-off. That's something we need before your Pull Request can be merged. Please see our contributing guide.
Tip: if you only have one commit so far then run: git commit --amend --signoff and then git push --force.

@derek derek bot added the no-dco label Nov 17, 2020
@codecov
Copy link

codecov bot commented Nov 17, 2020

Codecov Report

Merging #1169 (71988a0) into master (b64f4bb) will decrease coverage by 0.30%.
The diff coverage is 2.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1169      +/-   ##
==========================================
- Coverage   34.57%   34.26%   -0.31%     
==========================================
  Files          65       66       +1     
  Lines        5440     5489      +49     
==========================================
  Hits         1881     1881              
- Misses       3355     3404      +49     
  Partials      204      204              
Impacted Files Coverage Δ
cmd/up/stignore.go 0.00% <0.00%> (ø)
cmd/up/up.go 3.24% <0.00%> (-0.02%) ⬇️
cmd/init/init.go 12.02% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b64f4bb...71988a0. Read the comment docs.

continue
}

if err := askIfUpdatingStignore(folder.LocalPath, stignorePath, gitPath); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is going to cause that we ask the user every time. I don't think we should do this unless we can do it only once per repo. I think that adding the .git to the .stignore we generate is good enough without being annoying about it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will handle to ask only once. This is important, I see lots of users without .git on their .stignore file, which makes okteto up very inestable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you know how this users are creating the .stignore? are they doing it by hand, or getting it from our samples / init command?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

must be manually because we always include .git

cmd/up/stignore.go Outdated Show resolved Hide resolved
cmd/up/stignore.go Outdated Show resolved Hide resolved

if !answer {
stignoreContent := ""
if model.FileExists(gitPath) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's just put it all the time, it's pretty standard to have it as part of an ignore list.

if model.FileExists(gitPath) {
stignoreContent = ".git\n"
}
if err := ioutil.WriteFile(stignorePath, []byte(stignoreContent), 0644); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the user chose no as the answer, why do we still create the ignore file?

Copy link
Contributor Author

@pchico83 pchico83 Nov 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It servers two goals:

  • only ask once
  • more discoverability of the feature

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but it goes against what you're asking the user. if they are asked "should I create the stignore file", they say no, and the file is still created they are going to think there's a bug. if you want to always create the file, then don't ask them (I don't think this is right approach btw).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you suggest?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the user says no, we don't create the file, and don't ask them again for that repo.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand the painpoint, but we need to find a way to educate the user rather than ignore their answers. I think we should explain why synchronizing .git is a bad idea, but if they want to do it, it's their choice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, but the implementation of "don't ask them again for that repo" must live in the repo. If not, every time a user clones the repo will get prompted, and that feels wrong because okteto has been already configured.
I will rephrase the question to make it clear.

Copy link
Contributor

@rlamana rlamana Nov 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It did look like a rephrasing issue. I like it better now, but maybe we should also state the benefits of doing so. What about something like:
Okteto requires a '.stignore' file to intentionally ignore file patterns that help optimize the synchronization service.

cmd/up/stignore.go Outdated Show resolved Hide resolved
if err != nil {
return fmt.Errorf("failed to get language for '%s': %s", folder, err.Error())
}
c := linguist.GetSTIgnore(language)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's make sure all of them include .git

@pchico83 pchico83 force-pushed the stignore branch 2 times, most recently from 951d63b to 9120c7d Compare November 18, 2020 10:51
cmd/up/stignore.go Outdated Show resolved Hide resolved
pchico83 and others added 4 commits November 19, 2020 06:59
Signed-off-by: Pablo Chico de Guzman <pchico83@gmail.com>
Co-authored-by: Ramón Lamana <rlamana@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants