<commit_before>package main

import (
	"fmt"
	"html/template"
	"log"
	"os"
	"strconv"

	"github.com/codegangsta/cli"
	"github.com/drone/drone-go/drone"
)

var deployCmd = cli.Command{
	Name:  "deploy",
	Usage: "deploy code",
	Action: func(c *cli.Context) {
		if err := deploy(c); err != nil {
			log.Fatalln(err)
		}
	},
	Flags: []cli.Flag{
		cli.StringFlag{
			Name:  "format",
			Usage: "format output",
			Value: tmplDeployInfo,
		},
	},
}

func deploy(c *cli.Context) error {
	repo := c.Args().First()
	owner, name, err := parseRepo(repo)
	if err != nil {
		return err
	}
	number, err := strconv.Atoi(c.Args().Get(1))
	if err != nil {
		return err
	}

	client, err := newClient(c)
	if err != nil {
		return err
	}

	build, err := client.Build(owner, name, number)
	if err != nil {
		return err
	}
	if build.Event == drone.EventPull {
		return fmt.Errorf("Cannot deploy a pull request")
	}
	env := c.Args().Get(2)
	if env == "" {
		return fmt.Errorf("Please specify the target environment (ie production)")
	}

	deploy, err := client.Deploy(owner, name, number, env)
	if err != nil {
		return err
	}

	tmpl, err := template.New("_").Parse(c.String("format"))<commit_msg>remove referene to external package<commit_after>package main

import (
	"fmt"
	"html/template"
	"log"
	"os"
	"strconv"

	"github.com/codegangsta/cli"
	"github.com/drone/drone/model"
)

var deployCmd = cli.Command{
	Name:  "deploy",
	Usage: "deploy code",
	Action: func(c *cli.Context) {
		if err := deploy(c); err != nil {
			log.Fatalln(err)
		}
	},
	Flags: []cli.Flag{
		cli.StringFlag{
			Name:  "format",
			Usage: "format output",
			Value: tmplDeployInfo,
		},
	},
}

func deploy(c *cli.Context) error {
	repo := c.Args().First()
	owner, name, err := parseRepo(repo)
	if err != nil {
		return err
	}
	number, err := strconv.Atoi(c.Args().Get(1))
	if err != nil {
		return err
	}

	client, err := newClient(c)
	if err != nil {
		return err
	}

	build, err := client.Build(owner, name, number)
	if err != nil {
		return err
	}
	if build.Event == model.EventPull {
		return fmt.Errorf("Cannot deploy a pull request")
	}
	env := c.Args().Get(2)
	if env == "" {
		return fmt.Errorf("Please specify the target environment (ie production)")
	}

	deploy, err := client.Deploy(owner, name, number, env)
	if err != nil {
		return err
	}

	tmpl, err := template.New("_").Parse(c.String("format"))
{'fraction_non_alphanumeric': 0.1704016913319239, 'fraction_numerical': 0.0016913319238900633, 'mean_word_length': 3.4307116104868913, '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': '6764969', 'n_tokens_mistral': 970, 'n_tokens_neox': 914, 'n_words': 229}