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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃彈 Count all cherry picks when setting the version #32689

Merged
merged 4 commits into from Mar 1, 2021

Conversation

estherkim
Copy link
Collaborator

Use case: When cherry-picking, sometimes a non-master commit needs to be cherry-picked to resolve merge conflicts.

What happens: A new AMP version is created instead of appending the existing AMP version with the # of cherry-picked commits.

This is because it grabs the wrong timestamp with HEAD~{# of master cherry-picked commits}

Example: amp-release-2012301722002, which has 2 master commits and 2 non-master commits, was created as release 2101152047000 instead of the expected 2012301722004 (or 2012301722002 depending on how we want to count).

Fix: Count both master and non-master commits when setting the AMP version.

@amp-owners-bot
Copy link

Hey @danielrozenberg! These files were changed:

build-system/compile/internal-version.js

Comment on lines -185 to -188
.map((line) => ({
isCherryPick: line.substring(0, 2) == '- ',
sha: line.substring(2),
}));
Copy link
Member

Choose a reason for hiding this comment

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

Some musings: we had these lines originally to forcefully indicate non-cherry-pick commits. The real issue we have here is that it's (afaiu) programmatically impossible to tell whether a modified commit is a indeed cherry pick or not

This resolved the issue at hand, but returns the original issue that this was supposed to fix, which is that we wanted to have an indicator for when somebody is trying to release a potentially unauthorized version. Not sure how to resolve both of these issues together

Comment on lines -409 to -411
// TODO(#27771, danielrozenberg): fail this release quickly if there are
// commits in the tree that are not from the `master` branch.

Copy link
Member

Choose a reason for hiding this comment

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

lol yes I'm talking above about exactly this TODO 馃槄

Copy link
Contributor

@jridgewell jridgewell left a comment

Choose a reason for hiding this comment

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

This effectively reverts #29051, which we introduced because some cherry-picks were not being properly picked up as cherry-picks. I can't remember the scenarios where this happens, but I think this is going to actually cause more incorrectly-versioned issues.

@estherkim
Copy link
Collaborator Author

An example would really help here. I haven't seen any instances where git cherry doesn't get the right # of commits.

However I have seen git cherry annotate a + when it should be a -. Example:

% git cherry upstream/master upstream/amp-release-2101300534005
- 0baf344463931f5b0ed5ca8518375bb71d4960a4
- 6a07a7ac04adf2b2d514455312e1c835499bf2e4
+ d0406efd81b2ffbc1adef4d1c208d1e74d92477e
- e3d046e0e17ba71e4fe748130037cc699deebe2a
- 84c4ecb7d4828fc55d9d301c5dee7defd723252

Is that the rare mis-categorization you're talking about?

@jridgewell
Copy link
Contributor

(For reference, upstream/master is currently 4ebe517)

Yah, that's a perfect example. I have no idea why d0406ef isn't being marked as a proper cherry-pick here.

@estherkim
Copy link
Collaborator Author

Hmm does the + matter though? We just need the number of commits the branch is ahead.

@jridgewell
Copy link
Contributor

Hmm does the + matter though? We just need the number of commits the branch is ahead.

Yes. For instance, if I check out one of my PR branches and run git cherry, I see a + SHA:

$ git cherry upstream/master blurry-placeholder-no-js
+ de03f31cb5fca2ed5365beb3e151d5e88953906c

This commit doesn't exist on master (PR isn't merged yet), so it shouldn't count as a cherry-pick.

@estherkim
Copy link
Collaborator Author

That's okay IMO because

  1. this adds support for non-master commits to fix the example I added in the PR description, and
  2. a dev branch isn't really a use case; this is for release automation to run on release branches

Copy link
Contributor

@jridgewell jridgewell left a comment

Choose a reason for hiding this comment

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

I think we need to immediately follow up with a PR that verifies the commits exist on master, but this is good enough to unblock us.

@rsimha rsimha merged commit f26666e into ampproject:master Mar 1, 2021
jridgewell pushed a commit that referenced this pull request Mar 1, 2021
jridgewell pushed a commit that referenced this pull request Mar 2, 2021
@estherkim estherkim deleted the count-all-cherry-picks branch July 23, 2021 15:29
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.

None yet

5 participants