You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: source.go
    path of file: ./repos/goreleaser/internal/pipe/sourcearchive
    
    the code of the file until where you have to start completion: // Package sourcearchive archives the source of the project using git-archive.
package sourcearchive

import (
	"fmt"
	"os"
	"path/filepath"

	"github.com/caarlos0/log"
	"github.com/goreleaser/goreleaser/internal/archivefiles"
	"github.com/goreleaser/goreleaser/internal/artifact"
	"github.com/goreleaser/goreleaser/internal/deprecate"
	"github.com/goreleaser/goreleaser/internal/gio"
	"github.com/goreleaser/goreleaser/internal/git"
	"github.com/goreleaser/goreleaser/internal/tmpl"
	"github.com/goreleaser/goreleaser/pkg/archive"
	"github.co
    
func (Pipe) Run(ctx *context.Context) error {
	format := ctx.Config.Source.Format
	if format != "zip" && format != "tar" && format != "tgz" && format != "tar.gz" {
		return fmt.Errorf("invalid source archive format: %s", format)
	}
	name, err := tmpl.New(ctx).Apply(ctx.Config.Source.NameTemplate)
	if err != nil {
		return err
	}
	filename := name + "." + format
	path := filepath.Join(ctx.Config.Dist, filename)
	log.WithField("file", filename).Info("creating source archive")
	args := []string{
		"archive",
		"-o", path,
	}

	prefix := ""
	if ctx.Config.Source.PrefixTemplate != "" {
		pt, err := tmpl.New(ctx).Apply(ctx.Config.Source.PrefixTemplate)
		if err != nil {
			return err
		}
		prefix = pt
		args = append(args, "--prefix", prefix)
	}
	args = append(args, ctx.Git.FullCommit)

	if _, err := git.Clean(git.Run(ctx, args...)); err != nil {
		return err
	}

	if len(ctx.Config.Source.Files) > 0 {
		if err := appendExtraFilesToArchive(ctx, prefix, path, format); err != nil {
			return err
		}
	}

	ctx.Artifacts.Add(&artifact.Artifact{
		Type: artifact.UploadableSourceArchive,
		Name: filename,
		Path: path,
		Extra: map[string]interface{}{
			artifact.ExtraFormat: format,
		},
	})
	return err
}