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

fix(436): Fix Missing/wrong pull requests for github commits #831

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dark0dave
Copy link
Contributor

@dark0dave dark0dave commented Aug 30, 2024

Description

fixes #436

Motivation and Context

How Has This Been Tested?

Screenshots / Logs (if applicable)

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (no code change)
  • Refactor (refactoring production code)
  • Other

Checklist:

  • My code follows the code style of this project.
  • I have updated the documentation accordingly.
  • I have formatted the code with rustfmt.
  • I checked the lints with clippy.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@dark0dave dark0dave force-pushed the fix/436 branch 4 times, most recently from 7f85647 to 18754e2 Compare August 30, 2024 10:43
let pull_request = pull_requests
.iter()
.find(|pr| pr.merge_commit() == Some(v.id().clone()));
debug!("-------------------------");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

these will be removed don't worry

@orhun
Copy link
Owner

orhun commented Sep 1, 2024

Looks good, do we need to remove the macro after this? Or what is in your mind?

Also, let me know if it is ready for testing 🙂

@dark0dave
Copy link
Contributor Author

dark0dave commented Sep 1, 2024

Looks good, do we need to remove the macro after this? Or what is in your mind?

Also, let me know if it is ready for testing 🙂'

For now keep the macro, whats on my mind currently is do we want to mark all the commits in a pr as contributors?

Example:

Old head                   *
                              \
I open pr 1 commit             *
                               |
You add a commit               *
                             /    
Alice merges commit        *       (merge commit)

Should I be a contributor as well as you? Currently I am just taking the commit before the merge commit ( ie in the above example you would be the contributor).

We don't need the to poll the api to get the pr commit history. The parent commits of the pr allow us to work backwards via the tree and discover the other relevant commits for that pr.

@orhun
Copy link
Owner

orhun commented Sep 1, 2024

Should I be a contributor as well as you? Currently I am just taking the commit before the merge commit ( ie in the above example you would be the contributor).

Yes, I think that's reasonable.

We don't need the to poll the api to get the pr commit history. The parent commits of the pr allow us to work backwards via the tree and discover the other relevant commits for that pr.

Hmm, interesting. So we don't need to send 2 requests? Can you show me an example?

@dark0dave
Copy link
Contributor Author

dark0dave commented Sep 1, 2024

Should I be a contributor as well as you? Currently I am just taking the commit before the merge commit ( ie in the above example you would be the contributor).

Yes, I think that's reasonable.

We don't need the to poll the api to get the pr commit history. The parent commits of the pr allow us to work backwards via the tree and discover the other relevant commits for that pr.

Hmm, interesting. So we don't need to send 2 requests? Can you show me an example?

Let me clarify: We do need to list PRs and commits. We do not need to send a request for each prs commit history.

The github commit object exposes a parents field:

https://docs.github.com/en/rest/commits/commits?apiVersion=2022-11-28#list-commits

We can use this parents field to traverse the commit history, git history is after all a tree.

    "parents": [
      {
        "url": "https://api.github.com/repos/octocat/Hello-World/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e",
        "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e"
      }
    ]

Ie the above example with Alice, you and I. The Alice's merge commits parents are:

  • old head
  • your commit

Your commit's parent are:

  • my commit

My commit parent are:

  • old head

@orhun
Copy link
Owner

orhun commented Sep 2, 2024

Let me clarify: We do need to list PRs and commits. We do not need to send a request for each prs commit history.

wait, we don't do that already. We only fetch all the commits and PRs & try to link between them using the available fields (merge_commit_sha etc.)

Ie the above example with Alice, you and I. The Alice's merge commits parents are:

I see, I think it would be better to talk over the implementation :) Let me know when this is ready for review.

@orhun
Copy link
Owner

orhun commented Sep 21, 2024

ping :)

@dark0dave
Copy link
Contributor Author

@orhun so sorry I have been traveling for work. I'll ping you in a bit.

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

Successfully merging this pull request may close these issues.

Missing/wrong pull requests for commits
2 participants