<commit_before>package main

import (
	"fmt"
	"io"
	"io/ioutil"
	"log"
	"os"
	"path"
	"strings"

	ostree "github.com/sjoerdsimons/ostree-go/pkg/otbuiltin"
)

type OstreeDeployAction struct {
	*BaseAction
	Repository       string
	RemoteRepository string "remote_repository"
	Branch           string
	Os               string
}

func (ot *OstreeDeployAction) Run(context *YaibContext) {
	repoPath := "file://" + path.Join(context.artifactdir, ot.Repository)

	sysroot := ostree.NewSysroot(context.imageMntDir)
	err := sysroot.InitializeFS()
	if err != nil {
		log.Fatal(err)
	}

	err = sysroot.InitOsname(ot.Os, nil)
	if err != nil {
		log.Fatalf("%s", err)
	}

	dstRepo, err := sysroot.Repo(nil)
	if err != nil {
		log.Fatalf("%s", err)
	}

	err = dstRepo.RemoteAdd("origin", ot.RemoteRepository, nil, nil)
	if err != nil {
		log.Fatalf("%s", err)
	}

	var options ostree.PullOptions
	options.OverrideRemoteName = "origin"
	options.Refs = []string{ot.Branch}

	err = dstRepo.PullWithOptions(repoPath, options, nil, nil)
	if err != nil {
		log.Fatalf("%s", err)
	}
<commit_msg>Hack around ostree incorrectly configuring repository<commit_after>package main

import (
	"fmt"
	"io"
	"io/ioutil"
	"log"
	"os"
	"path"
	"strings"

	ostree "github.com/sjoerdsimons/ostree-go/pkg/otbuiltin"
)

type OstreeDeployAction struct {
	*BaseAction
	Repository       string
	RemoteRepository string "remote_repository"
	Branch           string
	Os               string
}

func (ot *OstreeDeployAction) Run(context *YaibContext) {
	repoPath := "file://" + path.Join(context.artifactdir, ot.Repository)

	sysroot := ostree.NewSysroot(context.imageMntDir)
	err := sysroot.InitializeFS()
	if err != nil {
		log.Fatal(err)
	}

	err = sysroot.InitOsname(ot.Os, nil)
	if err != nil {
		log.Fatalf("%s", err)
	}

	/* HACK: Getting the repository form the sysroot gets ostree confused on
	 * whether it should configure /etc/ostree or the repo configuration,
	   so reopen by hand */
	/* dstRepo, err := sysroot.Repo(nil) */
	dstRepo, err = ostree.OpenRepo(path.Join(context.imageMntDir, "ostree/repo"))
	if err != nil {
		log.Fatalf("%s", err)
	}

	err = dstRepo.RemoteAdd("origin", ot.RemoteRepository, nil, nil)
	if err != nil {
		log.Fatalf("%s", err)
	}

	var options ostree.PullOptions
	options.OverrideRemoteName = "origin"
	options.Refs = []string{ot.Branch}

	err = dstRepo.PullWithOptions(repoPath, options, nil, nil)
	if err != nil {
		log.Fatalf("%s", err)
	}

{'fraction_non_alphanumeric': 0.1390593047034765, 'fraction_numerical': 0.0, 'mean_word_length': 3.7587548638132295, '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': '3183996', 'n_tokens_mistral': 924, 'n_tokens_neox': 911, 'n_words': 203}