-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen-gource-logs-on-repos.sh
48 lines (39 loc) · 1.42 KB
/
gen-gource-logs-on-repos.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
# Variables
GITHUB_API_URL="https://api.github.com"
ORGANIZATION="CMSGov"
TOKEN=$GITHUB_TOKEN # Set your environment variable to your GitHub Token
# Function to fetch repositories from the organization
fetch_repositories() {
curl -s -H "Authorization: token $TOKEN" "$GITHUB_API_URL/orgs/$ORGANIZATION/repos?per_page=100&page=$1"
}
GOURCE_LOG_LOC=$(readlink -f ./gource_logs)
cd $1
# Iterate through pages of repositories
page=1
while true; do
# Fetch repositories for the current page
response=$(fetch_repositories $page)
# Check if the response contains repositories
echo $response
if [[ $response == "[ \n ]" ]]; then
echo "No more repositories found."
break
fi
repo_names=$(echo "$response" | jq -r '.[] | .name')
for repo in $repo_names; do
echo "Processing repository: $repo"
# Add your code to process each repository here
# For example:
clone_url=$(echo "$response" | jq -r ".[] | select(.name == \"$repo\") | .clone_url")
echo "Cloning repository from: $clone_url"
git clone $clone_url || echo "failed or already exits"
cd $repo
git pull
cd ..
gource --output-custom-log "$GOURCE_LOG_LOC/pecos_${repo}.log" $1/$repo
sed -i -r -E "s#(.+)\|#\1|/$repo#" "$GOURCE_LOG_LOC/pecos_${repo}.log"
done
# Increment page number for the next iteration
page=$((page + 1))
done