From 7c9a180ebcae80cbb74dc78fae7154cde275e811 Mon Sep 17 00:00:00 2001
From: Arya Kiran
Date: Fri, 28 Apr 2023 12:08:42 +0530
Subject: [PATCH] add commitsbehind
---
pages/repo.go | 4 ++++
views/repo.html | 3 ++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/pages/repo.go b/pages/repo.go
index 24e2863..69f1b57 100644
--- a/pages/repo.go
+++ b/pages/repo.go
@@ -17,6 +17,7 @@ type Repo struct {
Parent string
Stars string
Forks string
+ CommitsBehind string
Watchers string
Language []string
License string
@@ -77,6 +78,9 @@ func HandleRepo(c *fiber.Ctx) error {
Scrape.Tags = append(Scrape.Tags, strings.TrimPrefix(el.Attr("data-octo-dimensions"), "topic:"))
})
})
+ sc.OnHTML("div.Box-body div.d-flex div span", func(e *colly.HTMLElement) {
+ Scrape.CommitsBehind = strings.TrimSuffix(e.ChildText("a"), " commits behind")
+ })
sc.OnHTML("div#readme", func(e *colly.HTMLElement) {
Scrape.Readme = e.ChildText("a[href='#readme']")
})
diff --git a/views/repo.html b/views/repo.html
index 5c4a852..0fb36ae 100644
--- a/views/repo.html
+++ b/views/repo.html
@@ -32,7 +32,8 @@
{{ end }} {{ if .Language }}
🗒️ {{range .Language}} {{.}} {{end}}
- {{end}}
+ {{end}} {{ if .CommitsBehind }} This repository is {{.CommitsBehind}}
+ commits behind its parent. {{end}}
{{end}} {{ if .files}}