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

feat: hook pre/post merge include merge source #8703

Merged
merged 8 commits into from
Feb 28, 2025
Merged

Conversation

nopcoder
Copy link
Contributor

@nopcoder nopcoder commented Feb 22, 2025

The new field merge_source include source branch/tag/commit as requested.
The current event include source_ref which resolved to the specific commit the merge operation will merge.

Close #8707

The new field `merge_source` include source branch/tag/commit as
requested.
The current event include `source_ref` which resolved to the specific
commit the merge operation will merge.
@nopcoder nopcoder added area/hooks improvements or additions to the hooks subsystem include-changelog PR description should be included in next release changelog labels Feb 22, 2025
@nopcoder nopcoder self-assigned this Feb 22, 2025
Copy link

github-actions bot commented Feb 22, 2025

♻️ PR Preview 6c09f27 has been successfully destroyed since this PR has been closed.

🤖 By surge-preview

Copy link

E2E Test Results - DynamoDB Local - Local Block Adapter

14 passed

Copy link

E2E Test Results - Quickstart

11 passed

@nopcoder nopcoder requested a review from a team February 25, 2025 14:18
@Isan-Rivkin Isan-Rivkin self-requested a review February 27, 2025 08:56
Copy link
Contributor

@Isan-Rivkin Isan-Rivkin left a comment

Choose a reason for hiding this comment

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

Thanks minor stuff about the doc and question about lua

| tag_id[^3] | The ID of the created/deleted tag | string |
| merge_source[^5] | The source branch/tag/ref on merge operation | string |
Copy link
Contributor

Choose a reason for hiding this comment

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

This renders as 4? (see image with purple arrow)
Screenshot 2025-02-27 at 11 38 12

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed this issue in the current docs - seems you can't compose

@@ -37,6 +38,7 @@ func marshalEventInformation(actionName, hookID string, record graveler.HookReco
CommitMessage: record.Commit.Message,
Committer: record.Commit.Committer,
CommitMetadata: record.Commit.Metadata,
MergeSource: record.MergeSource.String(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this left out from lua type on purpose? (https://github.com/treeverse/lakeFS/blob/master/pkg/actions/lua.go#L47)

Copy link
Contributor Author

@nopcoder nopcoder Feb 27, 2025

Choose a reason for hiding this comment

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

No, It is a bug - will fix it

@nopcoder nopcoder requested a review from Isan-Rivkin February 27, 2025 16:47
Copy link
Member

@N-o-Z N-o-Z left a comment

Choose a reason for hiding this comment

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

Thanks LGTM!
Just a couple of comments

@@ -20,6 +20,7 @@ type EventInfo struct {
CommitMessage string `json:"commit_message,omitempty"`
Committer string `json:"committer,omitempty"`
CommitMetadata map[string]string `json:"commit_metadata,omitempty"`
MergeSource string `json:"merge_source,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

I was having trouble understanding the difference between MergeSource and SourceRef. I think documenting these fields will greatly improve readability

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Documented in the HookRecord struct and part of the invoke

Copy link
Member

Choose a reason for hiding this comment

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

I think it's better to document it on the struct itself rather than where it is being used

Copy link
Contributor Author

@nopcoder nopcoder Feb 28, 2025

Choose a reason for hiding this comment

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

HookRecord is the structure that is used when we trigger hooks. The event is used for marshal the data for webhook and airflow.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry I thought you meant on the usage

RunID: postRunID,
Repository: repository,
BranchID: destination,
MergeSource: source,
Copy link
Member

Choose a reason for hiding this comment

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

nit: align field location in both pre and post hooks

CommitID: "123456789",
PreRunID: "3498032432",
TagID: "tag1",
MergeSource: "merge-source",
Copy link
Member

Choose a reason for hiding this comment

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

Do we have any place in the test where we verify the field? If not - what is the point of adding 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.

the test uses a golden file which I updated

Copy link
Contributor

@Isan-Rivkin Isan-Rivkin left a comment

Choose a reason for hiding this comment

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

LGTM Thanks! That's a great addition :)

@nopcoder nopcoder enabled auto-merge (squash) February 28, 2025 15:58
@nopcoder nopcoder disabled auto-merge February 28, 2025 16:18
@nopcoder nopcoder merged commit 8a484a6 into master Feb 28, 2025
42 checks passed
@nopcoder nopcoder deleted the feat/hook-merge-source branch February 28, 2025 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/hooks improvements or additions to the hooks subsystem include-changelog PR description should be included in next release changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hooks: Add Source Branch Name to Merge Events
3 participants