A fork of Gitea (see branch `mj`) adding Majority Judgment Polls 𐄷 over Issues and Merge Requests. https://git.mieuxvoter.fr
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.4 KiB

Use native git variants by default with go-git variants as build tag (#13673) * Move last commit cache back into modules/git Signed-off-by: Andrew Thornton <art27@cantab.net> * Remove go-git from the interface for last commit cache Signed-off-by: Andrew Thornton <art27@cantab.net> * move cacheref to last_commit_cache Signed-off-by: Andrew Thornton <art27@cantab.net> * Remove go-git from routers/private/hook Signed-off-by: Andrew Thornton <art27@cantab.net> * Move FindLFSFiles to pipeline Signed-off-by: Andrew Thornton <art27@cantab.net> * Make no-go-git variants Signed-off-by: Andrew Thornton <art27@cantab.net> * Submodule RefID Signed-off-by: Andrew Thornton <art27@cantab.net> * fix issue with GetCommitsInfo Signed-off-by: Andrew Thornton <art27@cantab.net> * fix GetLastCommitForPaths Signed-off-by: Andrew Thornton <art27@cantab.net> * Improve efficiency Signed-off-by: Andrew Thornton <art27@cantab.net> * More efficiency Signed-off-by: Andrew Thornton <art27@cantab.net> * even faster Signed-off-by: Andrew Thornton <art27@cantab.net> * Reduce duplication * As per @lunny Signed-off-by: Andrew Thornton <art27@cantab.net> * attempt to fix drone Signed-off-by: Andrew Thornton <art27@cantab.net> * fix test-tags Signed-off-by: Andrew Thornton <art27@cantab.net> * default to use no-go-git variants and add gogit build tag Signed-off-by: Andrew Thornton <art27@cantab.net> * placate lint Signed-off-by: Andrew Thornton <art27@cantab.net> * as per @6543 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2 years ago
  1. // Copyright 2015 The Gogs Authors. All rights reserved.
  2. // Copyright 2018 The Gitea Authors. All rights reserved.
  3. // Use of this source code is governed by a MIT-style
  4. // license that can be found in the LICENSE file.
  5. // +build gogit
  6. package git
  7. import (
  8. "fmt"
  9. "strings"
  10. "github.com/go-git/go-git/v5/plumbing/object"
  11. )
  12. func convertPGPSignature(c *object.Commit) *CommitGPGSignature {
  13. if c.PGPSignature == "" {
  14. return nil
  15. }
  16. var w strings.Builder
  17. var err error
  18. if _, err = fmt.Fprintf(&w, "tree %s\n", c.TreeHash.String()); err != nil {
  19. return nil
  20. }
  21. for _, parent := range c.ParentHashes {
  22. if _, err = fmt.Fprintf(&w, "parent %s\n", parent.String()); err != nil {
  23. return nil
  24. }
  25. }
  26. if _, err = fmt.Fprint(&w, "author "); err != nil {
  27. return nil
  28. }
  29. if err = c.Author.Encode(&w); err != nil {
  30. return nil
  31. }
  32. if _, err = fmt.Fprint(&w, "\ncommitter "); err != nil {
  33. return nil
  34. }
  35. if err = c.Committer.Encode(&w); err != nil {
  36. return nil
  37. }
  38. if _, err = fmt.Fprintf(&w, "\n\n%s", c.Message); err != nil {
  39. return nil
  40. }
  41. return &CommitGPGSignature{
  42. Signature: c.PGPSignature,
  43. Payload: w.String(),
  44. }
  45. }
  46. func convertCommit(c *object.Commit) *Commit {
  47. return &Commit{
  48. ID: c.Hash,
  49. CommitMessage: c.Message,
  50. Committer: &c.Committer,
  51. Author: &c.Author,
  52. Signature: convertPGPSignature(c),
  53. Parents: c.ParentHashes,
  54. }
  55. }