mirror of
https://github.com/apricote/releaser-pleaser.git
synced 2026-01-13 21:21:03 +00:00
feat: push branch with changelog
This commit is contained in:
parent
8199918903
commit
c7743e0a80
10 changed files with 313 additions and 36 deletions
27
git.go
27
git.go
|
|
@ -1,17 +1,22 @@
|
|||
package rp
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/go-git/go-git/v5"
|
||||
"github.com/go-git/go-git/v5/plumbing"
|
||||
"github.com/go-git/go-git/v5/plumbing/transport"
|
||||
)
|
||||
|
||||
const (
|
||||
CommitSearchDepth = 50 // TODO: Increase
|
||||
GitRemoteName = "origin"
|
||||
)
|
||||
|
||||
type Commit struct {
|
||||
|
|
@ -24,6 +29,28 @@ type Tag struct {
|
|||
Name string
|
||||
}
|
||||
|
||||
func CloneRepo(ctx context.Context, cloneURL, branch string, auth transport.AuthMethod) (*git.Repository, error) {
|
||||
dir, err := os.MkdirTemp("", "releaser-pleaser.*")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create temporary directory for repo clone: %w", err)
|
||||
}
|
||||
|
||||
// TODO: Log tmpdir
|
||||
fmt.Printf("Clone tmpdir: %s\n", dir)
|
||||
repo, err := git.PlainCloneContext(ctx, dir, false, &git.CloneOptions{
|
||||
URL: cloneURL,
|
||||
RemoteName: GitRemoteName,
|
||||
ReferenceName: plumbing.NewBranchReferenceName(branch),
|
||||
SingleBranch: false,
|
||||
Auth: auth,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to clone repository: %w", err)
|
||||
}
|
||||
|
||||
return repo, nil
|
||||
}
|
||||
|
||||
func ReleasableCommits(repo *git.Repository) ([]Commit, *Tag, error) {
|
||||
|
||||
ref, err := repo.Head()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue