dashboard / git-pr / chore: remove dead code #1 rss

accepted · opened on 2024-07-18T18:03:12Z by erock
Help
# add changes to patch request
git format-patch main --stdout | ssh pr.pico.sh pr add 1
# add review to patch request
git format-patch main --stdout | ssh pr.pico.sh pr add --review 1
# remove patchset
ssh pr.pico.sh ps rm ps-x
# checkout all patches
ssh pr.pico.sh pr print 1 | git am -3
# print a diff between the last two patches in a patch request
ssh pr.pico.sh pr diff 1
# accept PR
ssh pr.pico.sh pr accept 1
# close PR
ssh pr.pico.sh pr close 1

Logs

erock created pr with ps-1 on 2024-07-18T18:03:12Z
jolheiser changed status on 2024-07-18T18:17:18Z {"status":"accepted"}

Patchsets

ps-1 by erock on 2024-07-18T18:03:12Z

Patchset ps-1

chore: remove dead code

Eric Bower
2024-07-18T18:02:40Z
util.go
+0 -111
Back to top

chore: remove dead code

util.go link
+0 -111
  1diff --git a/util.go b/util.go
  2index 5c6e41e..abb0a68 100644
  3--- a/util.go
  4+++ b/util.go
  5@@ -6,12 +6,10 @@ import (
  6 	"encoding/hex"
  7 	"fmt"
  8 	"io"
  9-	"log/slog"
 10 	"math/rand"
 11 	"regexp"
 12 	"strconv"
 13 	"strings"
 14-	"time"
 15 
 16 	"github.com/bluekeyes/go-gitdiff/gitdiff"
 17 	"github.com/charmbracelet/ssh"
 18@@ -211,112 +209,3 @@ func calcContentSha(diffFiles []*gitdiff.File, header *gitdiff.PatchHeader) stri
 19 	shaStr := hex.EncodeToString(sha[:])
 20 	return shaStr
 21 }
 22-
 23-func AuthorDateToTime(date string, logger *slog.Logger) time.Time {
 24-	// TODO: convert sql column to DATETIME
 25-	ds, err := time.Parse("2006-01-02T15:04:05Z", date)
 26-	if err != nil {
 27-		logger.Error(
 28-			"cannot parse author date for patch",
 29-			"datetime", date,
 30-			"err", err,
 31-		)
 32-		return time.Now()
 33-	}
 34-	return ds
 35-}
 36-
 37-/* func filterPatches(ranger *Ranger, patches []*Patch) []*Patch {
 38-	if ranger.Left == ranger.Right {
 39-		return []*Patch{patches[ranger.Left]}
 40-	}
 41-	return patches[ranger.Left:ranger.Right]
 42-}
 43-
 44-type Ranger struct {
 45-	Left  int
 46-	Right int
 47-}
 48-
 49-func parseRange(rnge string, sliceLen int) (*Ranger, error) {
 50-	items := strings.Split(rnge, ":")
 51-	left := 0
 52-	var err error
 53-	if items[0] != "" {
 54-		left, err = strconv.Atoi(items[0])
 55-		if err != nil {
 56-			return nil, fmt.Errorf("first value before `:` must provide number")
 57-		}
 58-	}
 59-
 60-	if left < 0 {
 61-		return nil, fmt.Errorf("first value must be >= 0")
 62-	}
 63-
 64-	if left >= sliceLen {
 65-		return nil, fmt.Errorf("first value must be less than number of patches")
 66-	}
 67-
 68-	if len(items) == 1 {
 69-		return &Ranger{
 70-			Left:  left,
 71-			Right: left,
 72-		}, nil
 73-	}
 74-
 75-	if items[1] == "" {
 76-		return &Ranger{Left: left, Right: sliceLen - 1}, nil
 77-	}
 78-
 79-	right, err := strconv.Atoi(items[1])
 80-	if err != nil {
 81-		return nil, fmt.Errorf("second value after `:` must provide number")
 82-	}
 83-
 84-	if left > right {
 85-		return nil, fmt.Errorf("second value must be greater than first value")
 86-	}
 87-
 88-	if right >= sliceLen {
 89-		return nil, fmt.Errorf("second value must be less than number of patches")
 90-	}
 91-
 92-	return &Ranger{
 93-		Left:  left,
 94-		Right: right,
 95-	}, nil
 96-} */
 97-
 98-/* func gitServiceCommands(sesh ssh.Session, be *Backend, cmd, repoName string) error {
 99-	name := utils.SanitizeRepo(repoName)
100-	// git bare repositories should end in ".git"
101-	// https://git-scm.com/docs/gitrepository-layout
102-	repoID := be.RepoID(name)
103-	reposDir := be.ReposDir()
104-	err := git.EnsureWithin(reposDir, repoID)
105-	if err != nil {
106-		return err
107-	}
108-	repoPath := filepath.Join(reposDir, repoID)
109-	serviceCmd := git.ServiceCommand{
110-		Stdin:  sesh,
111-		Stdout: sesh,
112-		Stderr: sesh.Stderr(),
113-		Dir:    repoPath,
114-		Env:    sesh.Environ(),
115-	}
116-
117-	if cmd == "git-receive-pack" {
118-		err := git.ReceivePack(sesh.Context(), serviceCmd)
119-		if err != nil {
120-			return err
121-		}
122-	} else if cmd == "git-upload-pack" {
123-		err := git.UploadPack(sesh.Context(), serviceCmd)
124-		if err != nil {
125-			return err
126-		}
127-	}
128-
129-	return nil
130-} */