0

Our organisation is migrating from BitBucket to GitHub. We need to perform post-migration validation. Can someone please help with git commands for below:

  1. Get count of commits per repository. I have already tried below ones but they are not giving correct output:

    git rev-list --count [revision] git rev-list --all --count 
  2. Get count of open/merged/declined/ total PRs per repository.

  3. Get count of number of lines in a git repository. (Tried this SO accepted answer but it's not giving correct output in my case https://stackoverflow.com/questions/4822471/count-number-of-lines-in-a-git-repository#:~:text=Blank%20lines%20are%20counted.&text=This%20searches%20all%20files%20versioned,the%20total%20number%20of%20lines!&text=this%20works%20if%20you%20count,as%20the%20files%20of%20interest.)

7
  • 4
    Why do you distrust the output of git rev-list --all --count? ("they're not giving correct output") Commented Apr 27, 2021 at 7:46
  • 3
    Keep in mind that open/merged/declined/total PRs are not a property of the git repository itself. So whatever tool you use to migrate stuff needs to use BitBucket- and GitHub-specific APIs to transfer those. Commented Apr 27, 2021 at 7:48
  • 1
    doubling up on comment : can you explain what makes you say that git rev-list --count doesn't give the correct output ? more precisely : can you give more details on what actions you took (running it on your local working repository / on a fresh clone / on a colleague's clone / ... ) and what you expect (it looks like you expect to see a known number : is it a number that is displayed in bitbucket ? github ? your local repo ? ) Commented Apr 27, 2021 at 7:55
  • 1
    @RomainValeri I created a new repo to test the command. I created 3-4 branches and did few commits in each branch. I merged some PRs as well. I counted the commits for this repo manually and compared with the command output, it didn't match. Commented Apr 27, 2021 at 8:05
  • 3
    Additionally, try to write just 1 question in one post here. This question: "Get count of number of lines in a git repository" might be completely handled by "Get count of lines in files in a folder", but it depends on whether you think it might be different for a git repository, but it will warrant a completely set of answers and comments compared to counting commits. Commented Apr 27, 2021 at 8:13

1 Answer 1

1

Rather than figuring out the commits count between two clones, you will be better off writing a script that compares branches and commit hashes.

You can run :

git ls-remote [url to any git repo] 

to get a list of branches and references from a remote repository, and the current hash for each reference.

So you can run :

git ls-remote [url of bitbucket repo] > bitbucket.txt git ls-remote [url of github repo] > github.txt 

and compare these two files, to see if all the commits you expect have been moved from one repo to the other.

As noted in the comment : data like "Issues" or "Merge Requests" are not stored in the git repo directly, and must be checked using some other tools -- probably tools that rely on github and bitbucket APIs to get that data.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.