enhancement: allow callers to use custom loggers
This commit is contained in:
parent
ad004a1671
commit
102ff0427a
|
@ -45,7 +45,7 @@ func runFetch(_ *cobra.Command, _ []string) {
|
||||||
log.Fatalf("could not get working directory: %v", err)
|
log.Fatalf("could not get working directory: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = srpmproc.Fetch(cdnUrl, wd)
|
err = srpmproc.Fetch(os.Stdout, cdnUrl, wd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import (
|
||||||
"github.com/go-git/go-billy/v5"
|
"github.com/go-git/go-billy/v5"
|
||||||
"github.com/go-git/go-git/v5/plumbing/transport"
|
"github.com/go-git/go-git/v5/plumbing/transport"
|
||||||
"github.com/rocky-linux/srpmproc/pkg/blob"
|
"github.com/rocky-linux/srpmproc/pkg/blob"
|
||||||
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
type FsCreatorFunc func(branch string) (billy.Filesystem, error)
|
type FsCreatorFunc func(branch string) (billy.Filesystem, error)
|
||||||
|
@ -52,4 +53,5 @@ type ProcessData struct {
|
||||||
AllowStreamBranches bool
|
AllowStreamBranches bool
|
||||||
FsCreator FsCreatorFunc
|
FsCreator FsCreatorFunc
|
||||||
CdnUrl string
|
CdnUrl string
|
||||||
|
Log *log.Logger
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,6 @@ import (
|
||||||
"github.com/go-git/go-billy/v5"
|
"github.com/go-git/go-billy/v5"
|
||||||
"hash"
|
"hash"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
@ -93,9 +92,9 @@ func StrContains(a []string, b string) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if content and checksum matches
|
// CompareHash checks if content and checksum matches
|
||||||
// returns the hash type if success else nil
|
// returns the hash type if success else nil
|
||||||
func CompareHash(content []byte, checksum string) hash.Hash {
|
func (pd *ProcessData) CompareHash(content []byte, checksum string) hash.Hash {
|
||||||
var hashType hash.Hash
|
var hashType hash.Hash
|
||||||
|
|
||||||
switch len(checksum) {
|
switch len(checksum) {
|
||||||
|
@ -123,7 +122,7 @@ func CompareHash(content []byte, checksum string) hash.Hash {
|
||||||
|
|
||||||
calculated := hex.EncodeToString(hashType.Sum(nil))
|
calculated := hex.EncodeToString(hashType.Sum(nil))
|
||||||
if calculated != checksum {
|
if calculated != checksum {
|
||||||
log.Printf("wanted checksum %s, but got %s", checksum, calculated)
|
pd.Log.Printf("wanted checksum %s, but got %s", checksum, calculated)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ func add(cfg *srpmprocpb.Cfg, pd *data.ProcessData, md *data.ModeData, patchTree
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
hashFunction := data.CompareHash(replacingBytes, addType.Lookaside)
|
hashFunction := pd.CompareHash(replacingBytes, addType.Lookaside)
|
||||||
if hashFunction == nil {
|
if hashFunction == nil {
|
||||||
return errors.New(fmt.Sprintf("LOOKASIDE_HASH_DOES_NOT_MATCH:%s", addType.Lookaside))
|
return errors.New(fmt.Sprintf("LOOKASIDE_HASH_DOES_NOT_MATCH:%s", addType.Lookaside))
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,15 +24,13 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
|
|
||||||
"github.com/bluekeyes/go-gitdiff/gitdiff"
|
"github.com/bluekeyes/go-gitdiff/gitdiff"
|
||||||
"github.com/go-git/go-git/v5"
|
"github.com/go-git/go-git/v5"
|
||||||
srpmprocpb "github.com/rocky-linux/srpmproc/pb"
|
srpmprocpb "github.com/rocky-linux/srpmproc/pb"
|
||||||
"github.com/rocky-linux/srpmproc/pkg/data"
|
"github.com/rocky-linux/srpmproc/pkg/data"
|
||||||
)
|
)
|
||||||
|
|
||||||
func patch(cfg *srpmprocpb.Cfg, _ *data.ProcessData, _ *data.ModeData, patchTree *git.Worktree, pushTree *git.Worktree) error {
|
func patch(cfg *srpmprocpb.Cfg, pd *data.ProcessData, _ *data.ModeData, patchTree *git.Worktree, pushTree *git.Worktree) error {
|
||||||
for _, patch := range cfg.Patch {
|
for _, patch := range cfg.Patch {
|
||||||
patchFile, err := patchTree.Filesystem.Open(patch.File)
|
patchFile, err := patchTree.Filesystem.Open(patch.File)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -40,7 +38,7 @@ func patch(cfg *srpmprocpb.Cfg, _ *data.ProcessData, _ *data.ModeData, patchTree
|
||||||
}
|
}
|
||||||
files, _, err := gitdiff.Parse(patchFile)
|
files, _, err := gitdiff.Parse(patchFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("could not parse patch file: %v", err)
|
pd.Log.Printf("could not parse patch file: %v", err)
|
||||||
return errors.New(fmt.Sprintf("COULD_NOT_PARSE_PATCH_FILE:%s", patch.File))
|
return errors.New(fmt.Sprintf("COULD_NOT_PARSE_PATCH_FILE:%s", patch.File))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +56,7 @@ func patch(cfg *srpmprocpb.Cfg, _ *data.ProcessData, _ *data.ModeData, patchTree
|
||||||
|
|
||||||
err = gitdiff.NewApplier(patchSubjectFile).ApplyFile(&output, patchedFile)
|
err = gitdiff.NewApplier(patchSubjectFile).ApplyFile(&output, patchedFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("could not apply patch: %v", err)
|
pd.Log.Printf("could not apply patch: %v", err)
|
||||||
return errors.New(fmt.Sprintf("COULD_NOT_APPLY_PATCH_WITH_SUBJECT:%s", srcPath))
|
return errors.New(fmt.Sprintf("COULD_NOT_APPLY_PATCH_WITH_SUBJECT:%s", srcPath))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ func replace(cfg *srpmprocpb.Cfg, pd *data.ProcessData, _ *data.ModeData, patchT
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
hasher := data.CompareHash(bts, replacing.WithLookaside)
|
hasher := pd.CompareHash(bts, replacing.WithLookaside)
|
||||||
if hasher == nil {
|
if hasher == nil {
|
||||||
return errors.New("LOOKASIDE_FILE_AND_HASH_NOT_MATCHING")
|
return errors.New("LOOKASIDE_FILE_AND_HASH_NOT_MATCHING")
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/rocky-linux/srpmproc/pkg/misc"
|
"github.com/rocky-linux/srpmproc/pkg/misc"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
|
@ -142,7 +141,7 @@ func (g *GitMode) RetrieveSource(pd *data.ProcessData) (*data.ModeData, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, branch := range latestTags {
|
for _, branch := range latestTags {
|
||||||
log.Printf("tag: %s", strings.TrimPrefix(branch.remote, "refs/tags/"))
|
pd.Log.Printf("tag: %s", strings.TrimPrefix(branch.remote, "refs/tags/"))
|
||||||
branches = append(branches, *branch)
|
branches = append(branches, *branch)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,7 +178,7 @@ func (g *GitMode) WriteSource(pd *data.ProcessData, md *data.ModeData) error {
|
||||||
branchName = match[2]
|
branchName = match[2]
|
||||||
refspec = config.RefSpec(fmt.Sprintf("+refs/heads/%s:%s", branchName, md.TagBranch))
|
refspec = config.RefSpec(fmt.Sprintf("+refs/heads/%s:%s", branchName, md.TagBranch))
|
||||||
}
|
}
|
||||||
log.Printf("checking out upstream refspec %s", refspec)
|
pd.Log.Printf("checking out upstream refspec %s", refspec)
|
||||||
err = remote.Fetch(&git.FetchOptions{
|
err = remote.Fetch(&git.FetchOptions{
|
||||||
RemoteName: "upstream",
|
RemoteName: "upstream",
|
||||||
RefSpecs: []config.RefSpec{refspec},
|
RefSpecs: []config.RefSpec{refspec},
|
||||||
|
@ -205,7 +204,7 @@ func (g *GitMode) WriteSource(pd *data.ProcessData, md *data.ModeData) error {
|
||||||
|
|
||||||
metadataFile, err := md.Worktree.Filesystem.Open(fmt.Sprintf(".%s.metadata", md.Name))
|
metadataFile, err := md.Worktree.Filesystem.Open(fmt.Sprintf(".%s.metadata", md.Name))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("warn: could not open metadata file, so skipping: %v", err)
|
pd.Log.Printf("warn: could not open metadata file, so skipping: %v", err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,7 +232,7 @@ func (g *GitMode) WriteSource(pd *data.ProcessData, md *data.ModeData) error {
|
||||||
|
|
||||||
if md.BlobCache[hash] != nil {
|
if md.BlobCache[hash] != nil {
|
||||||
body = md.BlobCache[hash]
|
body = md.BlobCache[hash]
|
||||||
log.Printf("retrieving %s from cache", hash)
|
pd.Log.Printf("retrieving %s from cache", hash)
|
||||||
} else {
|
} else {
|
||||||
fromBlobStorage, err := pd.BlobStorage.Read(hash)
|
fromBlobStorage, err := pd.BlobStorage.Read(hash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -241,10 +240,10 @@ func (g *GitMode) WriteSource(pd *data.ProcessData, md *data.ModeData) error {
|
||||||
}
|
}
|
||||||
if fromBlobStorage != nil && !pd.NoStorageDownload {
|
if fromBlobStorage != nil && !pd.NoStorageDownload {
|
||||||
body = fromBlobStorage
|
body = fromBlobStorage
|
||||||
log.Printf("downloading %s from blob storage", hash)
|
pd.Log.Printf("downloading %s from blob storage", hash)
|
||||||
} else {
|
} else {
|
||||||
url := fmt.Sprintf("%s/%s/%s/%s", pd.CdnUrl, md.Name, branchName, hash)
|
url := fmt.Sprintf("%s/%s/%s/%s", pd.CdnUrl, md.Name, branchName, hash)
|
||||||
log.Printf("downloading %s", url)
|
pd.Log.Printf("downloading %s", url)
|
||||||
|
|
||||||
req, err := http.NewRequest("GET", url, nil)
|
req, err := http.NewRequest("GET", url, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -275,7 +274,7 @@ func (g *GitMode) WriteSource(pd *data.ProcessData, md *data.ModeData) error {
|
||||||
return fmt.Errorf("could not open file pointer: %v", err)
|
return fmt.Errorf("could not open file pointer: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
hasher := data.CompareHash(body, hash)
|
hasher := pd.CompareHash(body, hash)
|
||||||
if hasher == nil {
|
if hasher == nil {
|
||||||
return fmt.Errorf("checksum in metadata does not match dist-git file")
|
return fmt.Errorf("checksum in metadata does not match dist-git file")
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/rocky-linux/srpmproc/pkg/data"
|
"github.com/rocky-linux/srpmproc/pkg/data"
|
||||||
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -12,7 +13,11 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Fetch(cdnUrl string, dir string) error {
|
func Fetch(logger io.Writer, cdnUrl string, dir string) error {
|
||||||
|
pd := &data.ProcessData{
|
||||||
|
Log: log.New(logger, "", log.LstdFlags),
|
||||||
|
}
|
||||||
|
|
||||||
metadataPath := ""
|
metadataPath := ""
|
||||||
err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
|
err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
|
||||||
if strings.HasSuffix(path, ".metadata") {
|
if strings.HasSuffix(path, ".metadata") {
|
||||||
|
@ -53,7 +58,7 @@ func Fetch(cdnUrl string, dir string) error {
|
||||||
path := lineInfo[1]
|
path := lineInfo[1]
|
||||||
|
|
||||||
url := fmt.Sprintf("%s/%s", cdnUrl, hash)
|
url := fmt.Sprintf("%s/%s", cdnUrl, hash)
|
||||||
log.Printf("downloading %s", url)
|
pd.Log.Printf("downloading %s", url)
|
||||||
|
|
||||||
req, err := http.NewRequest("GET", url, nil)
|
req, err := http.NewRequest("GET", url, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -75,7 +80,7 @@ func Fetch(cdnUrl string, dir string) error {
|
||||||
return fmt.Errorf("could not close body handle: %v", err)
|
return fmt.Errorf("could not close body handle: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
hasher := data.CompareHash(body, hash)
|
hasher := pd.CompareHash(body, hash)
|
||||||
if hasher == nil {
|
if hasher == nil {
|
||||||
return fmt.Errorf("checksum in metadata does not match dist-git file")
|
return fmt.Errorf("checksum in metadata does not match dist-git file")
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ func cfgPatches(pd *data.ProcessData, md *data.ModeData, patchTree *git.Worktree
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("applying directive %s", info.Name())
|
pd.Log.Printf("applying directive %s", info.Name())
|
||||||
filePath := filepath.Join("ROCKY/CFG", info.Name())
|
filePath := filepath.Join("ROCKY/CFG", info.Name())
|
||||||
directive, err := patchTree.Filesystem.Open(filePath)
|
directive, err := patchTree.Filesystem.Open(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -137,7 +137,7 @@ func executePatchesRpm(pd *data.ProcessData, md *data.ModeData) error {
|
||||||
err = repo.Fetch(fetchOptions)
|
err = repo.Fetch(fetchOptions)
|
||||||
|
|
||||||
refName := plumbing.NewBranchReferenceName(md.PushBranch)
|
refName := plumbing.NewBranchReferenceName(md.PushBranch)
|
||||||
log.Printf("set reference to ref: %s", refName)
|
pd.Log.Printf("set reference to ref: %s", refName)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// no patches active
|
// no patches active
|
||||||
|
@ -197,9 +197,9 @@ func getTipStream(pd *data.ProcessData, module string, pushBranch string, origPu
|
||||||
Auth: pd.Authenticator,
|
Auth: pd.Authenticator,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("could not import module: %s", module)
|
pd.Log.Printf("could not import module: %s", module)
|
||||||
if tries < 3 {
|
if tries < 3 {
|
||||||
log.Printf("could not get rpm refs. will retry in 3s. %v", err)
|
pd.Log.Printf("could not get rpm refs. will retry in 3s. %v", err)
|
||||||
time.Sleep(3 * time.Second)
|
time.Sleep(3 * time.Second)
|
||||||
return getTipStream(pd, module, pushBranch, origPushBranch, tries+1)
|
return getTipStream(pd, module, pushBranch, origPushBranch, tries+1)
|
||||||
}
|
}
|
||||||
|
@ -302,7 +302,7 @@ func patchModuleYaml(pd *data.ProcessData, md *data.ModeData) error {
|
||||||
|
|
||||||
log.Println("This module contains the following rpms:")
|
log.Println("This module contains the following rpms:")
|
||||||
for name := range module.Data.Components.Rpms {
|
for name := range module.Data.Components.Rpms {
|
||||||
log.Printf("\t- %s", name)
|
pd.Log.Printf("\t- %s", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultBranch := md.PushBranch
|
defaultBranch := md.PushBranch
|
||||||
|
|
|
@ -35,8 +35,10 @@ import (
|
||||||
"github.com/rocky-linux/srpmproc/pkg/misc"
|
"github.com/rocky-linux/srpmproc/pkg/misc"
|
||||||
"github.com/rocky-linux/srpmproc/pkg/modes"
|
"github.com/rocky-linux/srpmproc/pkg/modes"
|
||||||
"github.com/rocky-linux/srpmproc/pkg/rpmutils"
|
"github.com/rocky-linux/srpmproc/pkg/rpmutils"
|
||||||
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
"os/user"
|
"os/user"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -88,6 +90,7 @@ type ProcessDataRequest struct {
|
||||||
NoStorageDownload bool
|
NoStorageDownload bool
|
||||||
SingleTag string
|
SingleTag string
|
||||||
CdnUrl string
|
CdnUrl string
|
||||||
|
LogWriter io.Writer
|
||||||
}
|
}
|
||||||
|
|
||||||
func gitlabify(str string) string {
|
func gitlabify(str string) string {
|
||||||
|
@ -191,8 +194,14 @@ func NewProcessData(req *ProcessDataRequest) (*data.ProcessData, error) {
|
||||||
reqFsCreator = req.FsCreator
|
reqFsCreator = req.FsCreator
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var writer io.Writer = os.Stdout
|
||||||
|
if req.LogWriter != nil {
|
||||||
|
writer = req.LogWriter
|
||||||
|
}
|
||||||
|
logger := log.New(writer, "", log.LstdFlags)
|
||||||
|
|
||||||
if req.TmpFsMode != "" {
|
if req.TmpFsMode != "" {
|
||||||
log.Printf("using tmpfs dir: %s", req.TmpFsMode)
|
logger.Printf("using tmpfs dir: %s", req.TmpFsMode)
|
||||||
fsCreator = func(branch string) (billy.Filesystem, error) {
|
fsCreator = func(branch string) (billy.Filesystem, error) {
|
||||||
fs, err := reqFsCreator(branch)
|
fs, err := reqFsCreator(branch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -242,6 +251,7 @@ func NewProcessData(req *ProcessDataRequest) (*data.ProcessData, error) {
|
||||||
AllowStreamBranches: req.AllowStreamBranches,
|
AllowStreamBranches: req.AllowStreamBranches,
|
||||||
FsCreator: fsCreator,
|
FsCreator: fsCreator,
|
||||||
CdnUrl: req.CdnUrl,
|
CdnUrl: req.CdnUrl,
|
||||||
|
Log: logger,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -344,7 +354,7 @@ func ProcessRPM(pd *data.ProcessData) (*srpmprocpb.ProcessResponse, error) {
|
||||||
if strings.HasPrefix(md.TagBranch, prefix) {
|
if strings.HasPrefix(md.TagBranch, prefix) {
|
||||||
replace := strings.Replace(md.TagBranch, "refs/heads/", "", 1)
|
replace := strings.Replace(md.TagBranch, "refs/heads/", "", 1)
|
||||||
matchString = fmt.Sprintf("refs/tags/imports/%s/%s", replace, filepath.Base(pd.RpmLocation))
|
matchString = fmt.Sprintf("refs/tags/imports/%s/%s", replace, filepath.Base(pd.RpmLocation))
|
||||||
log.Printf("using match string: %s", matchString)
|
pd.Log.Printf("using match string: %s", matchString)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !misc.GetTagImportRegex(pd.ImportBranchPrefix, pd.AllowStreamBranches).MatchString(matchString) {
|
if !misc.GetTagImportRegex(pd.ImportBranchPrefix, pd.AllowStreamBranches).MatchString(matchString) {
|
||||||
|
@ -377,7 +387,7 @@ func ProcessRPM(pd *data.ProcessData) (*srpmprocpb.ProcessResponse, error) {
|
||||||
shouldContinue := true
|
shouldContinue := true
|
||||||
for _, ignoredTag := range tagIgnoreList {
|
for _, ignoredTag := range tagIgnoreList {
|
||||||
if ignoredTag == "refs/tags/"+newTag {
|
if ignoredTag == "refs/tags/"+newTag {
|
||||||
log.Printf("skipping %s", ignoredTag)
|
pd.Log.Printf("skipping %s", ignoredTag)
|
||||||
shouldContinue = false
|
shouldContinue = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -387,9 +397,9 @@ func ProcessRPM(pd *data.ProcessData) (*srpmprocpb.ProcessResponse, error) {
|
||||||
|
|
||||||
// create a new remote
|
// create a new remote
|
||||||
remoteUrl := fmt.Sprintf("%s/%s/%s.git", pd.UpstreamPrefix, remotePrefix, gitlabify(md.Name))
|
remoteUrl := fmt.Sprintf("%s/%s/%s.git", pd.UpstreamPrefix, remotePrefix, gitlabify(md.Name))
|
||||||
log.Printf("using remote: %s", remoteUrl)
|
pd.Log.Printf("using remote: %s", remoteUrl)
|
||||||
refspec := config.RefSpec(fmt.Sprintf("+refs/heads/%s:refs/remotes/origin/%s", md.PushBranch, md.PushBranch))
|
refspec := config.RefSpec(fmt.Sprintf("+refs/heads/%s:refs/remotes/origin/%s", md.PushBranch, md.PushBranch))
|
||||||
log.Printf("using refspec: %s", refspec)
|
pd.Log.Printf("using refspec: %s", refspec)
|
||||||
|
|
||||||
_, err = repo.CreateRemote(&config.RemoteConfig{
|
_, err = repo.CreateRemote(&config.RemoteConfig{
|
||||||
Name: "origin",
|
Name: "origin",
|
||||||
|
@ -407,7 +417,7 @@ func ProcessRPM(pd *data.ProcessData) (*srpmprocpb.ProcessResponse, error) {
|
||||||
})
|
})
|
||||||
|
|
||||||
refName := plumbing.NewBranchReferenceName(md.PushBranch)
|
refName := plumbing.NewBranchReferenceName(md.PushBranch)
|
||||||
log.Printf("set reference to ref: %s", refName)
|
pd.Log.Printf("set reference to ref: %s", refName)
|
||||||
|
|
||||||
var hash plumbing.Hash
|
var hash plumbing.Hash
|
||||||
if commitPin[md.PushBranch] != "" {
|
if commitPin[md.PushBranch] != "" {
|
||||||
|
@ -501,7 +511,7 @@ func ProcessRPM(pd *data.ProcessData) (*srpmprocpb.ProcessResponse, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
log.Printf("wrote %s to blob storage", checksum)
|
pd.Log.Printf("wrote %s to blob storage", checksum)
|
||||||
}
|
}
|
||||||
alreadyUploadedBlobs = append(alreadyUploadedBlobs, checksum)
|
alreadyUploadedBlobs = append(alreadyUploadedBlobs, checksum)
|
||||||
}
|
}
|
||||||
|
@ -541,7 +551,7 @@ func ProcessRPM(pd *data.ProcessData) (*srpmprocpb.ProcessResponse, error) {
|
||||||
|
|
||||||
// show status
|
// show status
|
||||||
status, _ := w.Status()
|
status, _ := w.Status()
|
||||||
log.Printf("successfully processed:\n%s", status)
|
pd.Log.Printf("successfully processed:\n%s", status)
|
||||||
|
|
||||||
statusLines := strings.Split(status.String(), "\n")
|
statusLines := strings.Split(status.String(), "\n")
|
||||||
for _, line := range statusLines {
|
for _, line := range statusLines {
|
||||||
|
@ -563,7 +573,7 @@ func ProcessRPM(pd *data.ProcessData) (*srpmprocpb.ProcessResponse, error) {
|
||||||
hashes = nil
|
hashes = nil
|
||||||
pushRefspecs = append(pushRefspecs, "*:*")
|
pushRefspecs = append(pushRefspecs, "*:*")
|
||||||
} else {
|
} else {
|
||||||
log.Printf("tip %s", head.String())
|
pd.Log.Printf("tip %s", head.String())
|
||||||
hashes = append(hashes, head.Hash())
|
hashes = append(hashes, head.Hash())
|
||||||
refOrigin := "refs/heads/" + md.PushBranch
|
refOrigin := "refs/heads/" + md.PushBranch
|
||||||
pushRefspecs = append(pushRefspecs, config.RefSpec(fmt.Sprintf("HEAD:%s", refOrigin)))
|
pushRefspecs = append(pushRefspecs, config.RefSpec(fmt.Sprintf("HEAD:%s", refOrigin)))
|
||||||
|
@ -588,7 +598,7 @@ func ProcessRPM(pd *data.ProcessData) (*srpmprocpb.ProcessResponse, error) {
|
||||||
return nil, fmt.Errorf("could not get commit object: %v", err)
|
return nil, fmt.Errorf("could not get commit object: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("committed:\n%s", obj.String())
|
pd.Log.Printf("committed:\n%s", obj.String())
|
||||||
|
|
||||||
_, err = repo.CreateTag(newTag, commit, &git.CreateTagOptions{
|
_, err = repo.CreateTag(newTag, commit, &git.CreateTagOptions{
|
||||||
Tagger: &object.Signature{
|
Tagger: &object.Signature{
|
||||||
|
|
Loading…
Reference in New Issue