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

Initial stab at enabling git submodule support in between meals #18

Closed
wants to merge 9 commits into from
Closed

Initial stab at enabling git submodule support in between meals #18

wants to merge 9 commits into from

Conversation

irabinovitch
Copy link

This is an initial stab at enabling git submodule support in between meals. Still doing a bit more testing but wanted to start the PR to get any feedback/concerns.

@@ -168,7 +173,7 @@ def parse_status(changes)
# X: "unknown" change type (most probably a bug, please report it)

# rubocop:disable MultilineBlockChain
changes.lines.map do |line|
changes.lines.to_a.reverse.map do |line|
Copy link
Contributor

Choose a reason for hiding this comment

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

Why?

Copy link
Author

Choose a reason for hiding this comment

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

To handle the case of a path being removed and re-added as a submodule. Before reversing the order it was only picking up the delete, and not the addition.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you provide an example git output? And incorporate that into the test cases? I've got a feeling this fix is incidental and possibly breaking other stuff.

@odcinek
Copy link
Contributor

odcinek commented Mar 31, 2015

Looks sane. Could you squash into single commit?

@irabinovitch
Copy link
Author

I believe these tests are broken on master as well.

@odcinek
Copy link
Contributor

odcinek commented Mar 31, 2015

Nope, they are not. .reverse breaks stuff.

@irabinovitch
Copy link
Author

Sorry for the delay was at ChefConf last week.

When you move an existing cookbook to a submodule the git history looks like:

A       .gitmodules
A       chef/cookbooks/foo
D       chef/cookbooks/foo/metadata.rb
D       chef/cookbooks/foo/recipes/default.rb
D       chef/cookbooks/foo/README.md

Between_Meals does detect all of the events and lists them properly in the Changes hash. However the above sequence results in a delete of the foo cookbook from the chef server, not an add/update

 DEBUG: [cookbook] chef/cookbooks/foo meaningful? [(?-mix:^chef\/cookbooks\/([^\/]+)\/.*)]:  

This is due to:

  • the change list deletes original metadata.rb but does not
  • meaningful_cookbook_file? returns false for chef/cookbooks/foo as it does not match against the regex in lib/between_meals/changes/cookbook.rb).

While the current hacks (reverse and relaxed regex) do hide this issue for our use case, they're not ideal as you've pointed out. My current thought is to add a gd_revision file for each submodule.

@jaymzh
Copy link
Collaborator

jaymzh commented Apr 7, 2015

Meanwhile if you move a cookbook, it'll show up as:

D chef/cookbooks/one/foo/metadata.rb
...
A chef/cookbooks/two/foo/metadata.rb
...

So not only are they sub-optimal, they'll break the common case. But moreover, we are doing all deletes before adds:

https://github.com/facebook/grocery-delivery/blob/master/bin/grocery-delivery#L130

So the problem here actually isn't the order (I'm confused as to how the .reverse even helps), it seems like the real problem is that we're not recognizing the add at all... is there a more verbose option to git log that will show the submodule changes in more detail?

@odcinek
Copy link
Contributor

odcinek commented Apr 13, 2015

@irabinovitch - this might be what you want

$ git submodule foreach git status --porcelain
Entering 'foo'
 A       metadata.rb
 A       recipes/default.rb
 A       README.md

somewhere around
https://github.com/facebook/between-meals/blob/master/lib/between_meals/repo/git.rb#L115

@odcinek
Copy link
Contributor

odcinek commented Apr 13, 2015

afaik the ordering of output is crucial here.

all the delete actions must go first. rename is a delete and add, in that order. moving a cookbook to a submodule should not be any different - explicit delete, followed by an add.

@jaymzh
Copy link
Collaborator

jaymzh commented Apr 24, 2015

@irabinovitch ?

@jaymzh
Copy link
Collaborator

jaymzh commented Jun 5, 2015

Pingaling?

@jaymzh
Copy link
Collaborator

jaymzh commented Jul 1, 2015

OK, closing after 3 months of no activity. If you get time to work on this again, please feel free to re-open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants