Sovenique
Sovenique

Reputation: 31

How can I grab specific SHA-1 hashes from remote repositories?

This script iterates multiple Git repositories in order to get their latest commit SHA-1 per branch. These commands are launched inside an arbitrary .git directory, so Git commands can be invoked without actually cloning any other repository.

git ls-remote https://$Username:[email protected]/r/repository1 > tmp/repository1
.
.
.
git ls-remote https://$Username:[email protected]/r/repository100 > tmp/repository100

A typical output per git ls-remote command would be (e.g. for repository1):

7898b741a5c6b7bd5ks93478600165905c3e96d2    HEAD
57e9fm46caf48eb82863e0278ee17c9332ee20d4    refs/heads/development
7898b741a5c6b7bd5ks93478600165905c3e96d2    refs/heads/master

Then each SHA-1 can be extracted and saved for instance as current_repository1_ref_heads_development=57e9fm46caf48eb82863e0278ee17c9332ee20d4

I'm wondering if it's possible to grab a SHA-1 that's not a heads (latest) and was pushed at a specific time ago (e.g. 60 minutes), so I can compare if current_repository1_ref_heads_development = previous_repository1_ref_heads_development, without cloning any of these repositories at all.

Thanks for reading!

Upvotes: 1

Views: 183

Answers (0)

Related Questions