summarylogtreecommitdiffstats
path: root/get-commit-count.sh
diff options
context:
space:
mode:
Diffstat (limited to 'get-commit-count.sh')
-rwxr-xr-xget-commit-count.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/get-commit-count.sh b/get-commit-count.sh
new file mode 100755
index 000000000000..7ecc4af2cdbd
--- /dev/null
+++ b/get-commit-count.sh
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+
+# Get the number of commits for a repository using the GitHub API
+# Requires curl and jq
+
+# Owner of the repository
+repo_owner="LazoCoder"
+
+# Name of the repository
+repo_name="Pokemon-Terminal"
+
+# URL for the API request
+repo_api_url="https://api.github.com/repos/${repo_owner}/${repo_name}"
+
+# Hashes of the first and the latest commits
+# Replace this with the hash of the first commit for your repository
+first_commit="767edcee47f4858f455d74621498d8703fcac1c5"
+
+# Hash of the latest commit is fetched through the GitHub API
+latest_commit=$(curl -s "$repo_api_url"/git/refs/heads/master | jq -r .object.sha)
+
+# Data returned by the GitHub API in JSON format
+github_data=$(curl -s "$repo_api_url"/compare/${first_commit}...${latest_commit})
+
+# Get the value of the total_commits key
+num_commits=$(echo "$github_data" | jq -r .total_commits)
+
+# Total number of commits = (value of the total_commits key) + 1
+echo $(( num_commits + 1 )) \ No newline at end of file