Skip to content

Commit

Permalink
ghbackup: init at 1.13.0 (#346918)
Browse files Browse the repository at this point in the history
  • Loading branch information
Scrumplex authored Nov 3, 2024
2 parents 59f20fb + f3c7acc commit aee9166
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 0 deletions.
5 changes: 5 additions & 0 deletions maintainers/maintainer-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12193,6 +12193,11 @@
github = "lenivaya";
githubId = 49302467;
};
lenny = {
name = "Lenny.";
matrix = "[email protected]";
keys = [ { fingerprint = "6D63 2D4D 0CFE 8D53 F5FD C7ED 738F C800 6E9E A634"; } ];
};
leo248 = {
github = "leo248";
githubId = 95365184;
Expand Down
44 changes: 44 additions & 0 deletions pkgs/by-name/gh/ghbackup/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
lib,
buildGoModule,
fetchFromGitHub,
git,
makeWrapper,
}:

buildGoModule rec {
pname = "ghbackup";
version = "1.13.0";

src = fetchFromGitHub {
owner = "qvl";
repo = "ghbackup";
rev = "v${version}";
hash = "sha256-3LSe805VrbUGjqjnhTJD2KBVZ4rq+4Z3l4d0I1MrBMA=";
};

patches = [ ./patches/fix-next-page-logic.patch ];

postPatch = ''
go mod init qvl.io/ghbackup
'';

nativeBuildInputs = [ makeWrapper ];

vendorHash = null;

postFixup = ''
wrapProgram $out/bin/${meta.mainProgram} \
--prefix PATH : "${lib.makeBinPath [ git ]}"
'';

doCheck = false; # tests want to actually download from github

meta = with lib; {
description = "Backup your GitHub repositories with a simple command-line application written in Go.";
homepage = "https://github.com/qvl/ghbackup";
license = licenses.mit;
mainProgram = "ghbackup";
maintainers = with maintainers; [ lenny ];
};
}
66 changes: 66 additions & 0 deletions pkgs/by-name/gh/ghbackup/patches/fix-next-page-logic.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
From 9825efc51387fef14fdb184e7061b313a54fcb86 Mon Sep 17 00:00:00 2001
From: Ronan Barrett <[email protected]>
Date: Mon, 8 May 2023 15:54:39 +0200
Subject: [PATCH 1/2] fix next page logic

---
ghbackup/fetch.go | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/ghbackup/fetch.go b/ghbackup/fetch.go
index 93cce1c..bcef8ad 100644
--- a/ghbackup/fetch.go
+++ b/ghbackup/fetch.go
@@ -126,11 +126,17 @@ func getNextURL(header http.Header) string {
if len(parts) == 0 {
return ""
}
- firstLink := parts[0]
- if !strings.Contains(firstLink, "rel=\"next\"") {
+ var nextLink string
+ for _, v := range parts {
+ if strings.Contains(v, "rel=\"next\"") {
+ nextLink = strings.TrimSpace(v)
+ }
+ }
+ if nextLink == "" {
return ""
}
- parts = strings.Split(firstLink, ";")
+
+ parts = strings.Split(nextLink, ";")
if len(parts) == 0 {
return ""
}
@@ -140,3 +146,4 @@ func getNextURL(header http.Header) string {
}
return urlInBrackets[1 : len(urlInBrackets)-1]
}
+

From 5f696939f668cd88c59c05fd8e0d6ad9f236dea5 Mon Sep 17 00:00:00 2001
From: Ronan Barrett <[email protected]>
Date: Mon, 8 May 2023 16:44:47 +0200
Subject: [PATCH 2/2] add break

---
ghbackup/fetch.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ghbackup/fetch.go b/ghbackup/fetch.go
index bcef8ad..b045c38 100644
--- a/ghbackup/fetch.go
+++ b/ghbackup/fetch.go
@@ -130,6 +130,7 @@ func getNextURL(header http.Header) string {
for _, v := range parts {
if strings.Contains(v, "rel=\"next\"") {
nextLink = strings.TrimSpace(v)
+ break
}
}
if nextLink == "" {
@@ -146,4 +147,3 @@ func getNextURL(header http.Header) string {
}
return urlInBrackets[1 : len(urlInBrackets)-1]
}
-

0 comments on commit aee9166

Please sign in to comment.