<commit_before>package main

import (
	"bytes"
	"fmt"
	"os"
	"path"

	log "github.com/Sirupsen/logrus"
	"github.com/drone/drone-plugin-go/plugin"
	"github.com/mikkeloscar/maze-repo/repo"
)

// ArchBuild defines the vargs passed from .drone.yml.
type ArchBuild struct {
	Repo     string `json:"repo"`
	SignKey  string `json:"sign_key"`
	Packager string `json:"packager"`
	// temp
	// Packages []string `json:"packages"`
}

func main() {
	// configure log
	log.SetFormatter(new(formatter))

	err := run()
	if err != nil {
		log.Error(err)
		os.Exit(1)
	}
}

type formatter struct{}

func (f *formatter) Format(entry *log.Entry) ([]byte, error) {
	buf := &bytes.Buffer{}
	fmt.Fprintf(buf, "[%s] %s\n", entry.Level.String(), entry.Message)
	return buf.Bytes(), nil
}

func run() error {
	// var repo = plugin.Repo{}
	// var build = plugin.Build{}
	var system = plugin.System{}
	var workspace = plugin.Workspace{}
	var vargs = ArchBuild{}

	// plugin.Param("repo", &repo)
	// plugin.Param("build", &build)
	plugin.Param("system", &system)
	plugin.Param("workspace", &workspace)
	plugin.Param("vargs", &vargs)
	plugin.MustParse()

	srcsPath := path.Join(workspace.Path, "drone_pkgbuild", "sources")
	repoPath := path.Join(workspace.Path, "drone_pkgbuild", "repo")

	// repoName, repoUrl, err := splitRepoDef(vargs.Repo)

	// pkgRepo := &Repo{
	// 	name:    repoName,
	// 	url:     repoUrl,
	// 	workdir: repoPath,
	// }

	// configure build
	if vargs.Packager == "" {
		vargs.Packager = "maze-build"
	}

	pkgRepo := &Repo{
		local: repo.Repo{
			Name: "repo",
			Path: repoPath,
		},
		url: repoPath,
	}

	builder := &Builder{
		workdir: srcsPath,
		repo:    pkgRepo,
		config:  vargs,
	}

	// aur := &AUR{srcsPath}

	// build, err := parseBuildURLInfo(system.Link, srcsPath)
	// if err != nil {
	// 	return err
	// }

	buildInst, err := parseGitLog(workspace.Path, srcsPath)
	if err != nil {
		return err
	}

	// buildInst := &BuildInst{
	// 	Pkgs: vargs.Packages,
	// 	Src:  &AUR{srcsPath},
	// }

	pkgs, err := builder.BuildNew(buildInst.Pkgs, buildInst.Src)
	if err != nil {
		return err
	}

	err = storeBuiltPkgs(path.Join(workspace.Path, "packages.built"), pkgs)
	if err != nil {
		return err
	}

	return nil
}
<commit_msg>Update packages.built path<commit_after>package main

import (
	"bytes"
	"fmt"
	"os"
	"path"

	log "github.com/Sirupsen/logrus"
	"github.com/drone/drone-plugin-go/plugin"
	"github.com/mikkeloscar/maze-repo/repo"
)

// ArchBuild defines the vargs passed from .drone.yml.
type ArchBuild struct {
	Repo     string `json:"repo"`
	SignKey  string `json:"sign_key"`
	Packager string `json:"packager"`
	// temp
	// Packages []string `json:"packages"`
}

func main() {
	// configure log
	log.SetFormatter(new(formatter))

	err := run()
	if err != nil {
		log.Error(err)
		os.Exit(1)
	}
}

type formatter struct{}

func (f *formatter) Format(entry *log.Entry) ([]byte, error) {
	buf := &bytes.Buffer{}
	fmt.Fprintf(buf, "[%s] %s\n", entry.Level.String(), entry.Message)
	return buf.Bytes(), nil
}

func run() error {
	// var repo = plugin.Repo{}
	// var build = plugin.Build{}
	var system = plugin.System{}
	var workspace = plugin.Workspace{}
	var vargs = ArchBuild{}

	// plugin.Param("repo", &repo)
	// plugin.Param("build", &build)
	plugin.Param("system", &system)
	plugin.Param("workspace", &workspace)
	plugin.Param("vargs", &vargs)
	plugin.MustParse()

	srcsPath := path.Join(workspace.Path, "drone_pkgbuild", "sources")
	repoPath := path.Join(workspace.Path, "drone_pkgbuild", "repo")

	// repoName, repoUrl, err := splitRepoDef(vargs.Repo)

	// pkgRepo := &Repo{
	// 	name:    repoName,
	// 	url:     repoUrl,
	// 	workdir: repoPath,
	// }

	// configure build
	if vargs.Packager == "" {
		vargs.Packager = "maze-build"
	}

	pkgRepo := &Repo{
		local: repo.Repo{
			Name: "repo",
			Path: repoPath,
		},
		url: repoPath,
	}

	builder := &Builder{
		workdir: srcsPath,
		repo:    pkgRepo,
		config:  vargs,
	}

	// aur := &AUR{srcsPath}

	// build, err := parseBuildURLInfo(system.Link, srcsPath)
	// if err != nil {
	// 	return err
	// }

	buildInst, err := parseGitLog(workspace.Path, srcsPath)
	if err != nil {
		return err
	}

	// buildInst := &BuildInst{
	// 	Pkgs: vargs.Packages,
	// 	Src:  &AUR{srcsPath},
	// }

	pkgs, err := builder.BuildNew(buildInst.Pkgs, buildInst.Src)
	if err != nil {
		return err
	}

	err = storeBuiltPkgs(path.Join(workspace.Path, "drone_pkgbuild", "packages.built"), pkgs)
	if err != nil {
		return err
	}

	return nil
}

{'fraction_non_alphanumeric': 0.17422381058744696, 'fraction_numerical': 0.00044672771945499217, 'mean_word_length': 3.39450441609421, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6548039', 'n_tokens_mistral': 1816, 'n_tokens_neox': 1759, 'n_words': 373}