How to find all commits by user to *any* repo in bitbucket?
Asked Answered
P

1

6

I have many repos, in which I need to find some commit I made a very long time ago. Due to reasons, I don't know which repos I have commits in, and when I did those commits.

I could go over them one by one, looking for when I did commits.

Is there some API or UI to just see all commits by a user, to any repo, sorted by time?

Pyrogallate answered 15/5, 2022 at 12:9 Comment(1)
The Git answer is: "I don't look anywhere but one repository on your computer: clone all your repos, and then run one Git command per repo to search them all on your own laptop". There might be a better-for-you Bitbucket web site or API answer, though.Henrik
S
5

You could use git's -C option with each of your repo paths to run git commands in them. Depending how your repos are locally organized, you may want to change how the paths are discovered. Change username to your committer email address. The pattern just needs to be unique, so you can probably leave off @example.com. Change the --before option as needed.

#!/usr/bin/env bash

for d in ~/path-to-repos/*/.git; do
    r=${d%.git}
    echo "$r"
    git -C "$r" log \
        --committer=username \
        --before=2013 \
        --reverse \
        --pretty='format:%h  %cd  %s'
done

You might want to experiment with git log's --pretty options.

Serpens answered 15/5, 2022 at 15:50 Comment(4)
This forces me to clone everything, I was looking to avoid that. Or, did you mean I can do that directly on the repos inside bitbucket somehow?Pyrogallate
You would need to clone them. I missed the part where you want to do this in Bitbucket.Serpens
Looks like you can get a listing of repos in Bitbucket using an API which would help automate cloning them all.Serpens
It might be good to add --no-pager option before the log command.Cheery

© 2022 - 2024 — McMap. All rights reserved.