summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorCharles Milette2017-08-19 15:09:19 -0400
committerCharles Milette2017-08-19 15:09:19 -0400
commitb54b69cf6948f35d7ccfc8dc4a81f357ab66439b (patch)
treece6ac2b23d6b389091372f07cad602e3aabd502b
parent391943001992207c97d9fd546e64b563cbd7d885 (diff)
downloadaur-b54b69cf6948f35d7ccfc8dc4a81f357ab66439b.tar.gz
It already broke
-rw-r--r--.SRCINFO6
-rw-r--r--PKGBUILD8
-rwxr-xr-xget-commit-count.pl12
-rwxr-xr-xget-commit-count.sh29
4 files changed, 36 insertions, 19 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 945ec0c21449..bd334cc87e67 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -6,15 +6,15 @@ pkgbase = pokemon-terminal-git
arch = any
license = GPL3
makedepends = git
- makedepends = perl
+ makedepends = jq
depends = python>=3.5
optdepends = gnome-shell: support changing GNOME wallpaper
optdepends = terminology: support changing Terminology background
optdepends = tilix: support changing Tilix background
source = https://github.com/LazoCoder/Pokemon-Terminal/archive/master.zip
- source = get-commit-count.pl
+ source = get-commit-count.sh
sha256sums = SKIP
- sha256sums = 6d4cc3bfb1f1b737c2f6ea1fac66302028f887056d0183b4c8ae2ed89ae70ef8
+ sha256sums = 714f2e21a5b77d8b72d6f75da1f1c2fac93f15e2ddd3829a3fbd6dc7307779d0
pkgname = pokemon-terminal-git
diff --git a/PKGBUILD b/PKGBUILD
index 56a3b461de80..ff0b322d8c55 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -12,13 +12,13 @@ depends=('python>=3.5')
optdepends=('gnome-shell: support changing GNOME wallpaper'
'terminology: support changing Terminology background'
'tilix: support changing Tilix background')
-makedepends=('git' 'perl')
-source=("https://github.com/LazoCoder/$_gitname/archive/master.zip" "get-commit-count.pl")
-sha256sums=('SKIP' '6d4cc3bfb1f1b737c2f6ea1fac66302028f887056d0183b4c8ae2ed89ae70ef8')
+makedepends=('git' 'jq')
+source=("https://github.com/LazoCoder/$_gitname/archive/master.zip" "get-commit-count.sh")
+sha256sums=('SKIP' '714f2e21a5b77d8b72d6f75da1f1c2fac93f15e2ddd3829a3fbd6dc7307779d0')
pkgver() {
cd "$srcdir"
- printf "r%s.%s" "$(curl --silent https://github.com/$_gitname/Pokemon-Terminal | ./get-commit-count.pl)" "$(git ls-remote https://github.com/LazoCoder/$_gitname.git refs/heads/master | cut -c1-7)"
+ printf "r%s.%s" "$(./get-commit-count.sh)" "$(git ls-remote https://github.com/LazoCoder/$_gitname.git refs/heads/master | cut -c1-7)"
}
package() {
diff --git a/get-commit-count.pl b/get-commit-count.pl
deleted file mode 100755
index 68f6d4770025..000000000000
--- a/get-commit-count.pl
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-
-local $/;
-my $stdin = <STDIN>;
-
-my $regex = qr/<span class="num text-emphasized">\n +(\d+)\n +<\/span>\n +commits/p;
-
-if ( $stdin =~ /$regex/g ) {
- print "$1";
-}
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