Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

[Question] Is it possible to see merged commits in a single merge ? #1487

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

Closed
mxrch opened this issue Sep 4, 2022 · 1 comment
Closed

[Question] Is it possible to see merged commits in a single merge ? #1487

mxrch opened this issue Sep 4, 2022 · 1 comment

Comments

@mxrch
Copy link
Contributor

mxrch commented Sep 4, 2022

Hi !
Is there a way to see merged commits by a merge ?
For example, this "Merge pull request" commit : jofpin/trape@6baae24
By looking at the pull request reference (https://github.com/jofpin/trape/pull/313/commits), we can see it has merged 3 commits : 98bae53, b17c6c1 and 626bca6.

In GitPython, by having the commit object 6baae24 (the merge), I can get the first merged commit (626bca6) by looking at the commit parents, but not the two others (logical, it's how Git works).
But using the git log command, I can extract them in raw :

(Pdb) repo.git.log("6baae24^..6baae24")
"commit 6baae245691997742a51979767254d7da580eadd\nMerge: e362980 626bca6\nAuthor: Jose Pino <[email protected]>\nDate:   Sun Jun 20 11:33:43 2021 -0500\n\n    Merge pull request #313 from captain-woof/typos_and_error_fixes\n    \n    Typos and error fixes\n\ncommit 626bca666b427998b2a5cf8753737425614c8a40\nAuthor: Captain Woof <[email protected]>\nDate:   Fri May 21 09:33:45 2021 +0530\n\n    Fixed the issue where user_objects module wasn't imported\n\ncommit b17c6c133e6a5a7049d28ca88faf267eb466fe65\nAuthor: Captain Woof <[email protected]>\nDate:   Fri May 21 08:59:36 2021 +0530\n\n    Fixed the 'unexpected keyword: version' issue\n\ncommit 98bae532d213b9692322fafdda1d4f9c19093bc5\nAuthor: Captain Woof <[email protected]>\nDate:   Fri May 21 08:22:38 2021 +0530\n\n    Changed 'python2' to 'python3' and os module import"

I can use a regex to parse them, but I would know if there is a more pythonic way implemented in GitPython to do this !
I didn't see ways for this in the documentation and the implemented methods. If there isn't actually a way to do this, why not adding it ?

Thank you in advance 😄

@mxrch mxrch changed the title [Question] Is it possible to see merged commits by a merge ? [Question] Is it possible to see merged commits in a single merge ? Sep 4, 2022
@mxrch
Copy link
Contributor Author

mxrch commented Sep 4, 2022

Temporary solution to extract hexsha of merged commits :

for commit in repo.iter_commits():
    if len(commit.parents) > 1:
        merged_commits = re.findall(r'\S{40}', repo.git.log(f"{commit.hexsha}^..{commit.hexsha}"))[1:]

@gitpython-developers gitpython-developers locked and limited conversation to collaborators Sep 4, 2022
@Byron Byron converted this issue into discussion #1488 Sep 4, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Development

No branches or pull requests

1 participant