<commit_before>/*
Copyright 2017 Toolhouse, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

	http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main

import (
	"encoding/json"
	"fmt"
	"net/http"
	"os"
	"strings"

	"github.com/hashicorp/go-multierror"
	"github.com/pkg/errors"
)

// The following environment variables are required for this script
const (
	URL    = "URL"
	COMMIT = "COMMIT"
	REF    = "REF"
)

// DeploymentManifest defines the JSON schema for a deployment manifest file
type DeploymentManifest struct {
	Commit string `json:"commit"`
	Ref    string `json:"ref"`
}

func main() {
	c, err := configFromEnv()
	if err != nil {
		os.Stderr.WriteString("Configuration issue: ")
		os.Stderr.WriteString(err.Error())
		os.Stderr.WriteString("\n")
		os.Exit(1)
	}

	err = verify(c.URL, c.Commit, c.Ref)
	if err != nil {
		os.Stderr.WriteString("Issue verifying deployment: ")
		os.Stderr.WriteString(err.Error())
		os.Stderr.WriteString("\n")
		os.Exit(1)
	}

	fmt.Println("Deployment verified")
	os.Exit(0)
}

func verify(url, commit, ref string) error {
	res, err := http.Get(url)
	if err != nil {
		return errors.Wrap(err, "Error fetching deployment manifest JSON")
	}

	if res.StatusCode < 200 || res.StatusCode > 299 {
		return errors.Errorf("Recieved non-200 HTTP status code: %s", res.Status)
	}

	defer res.Body.Close()<commit_msg>Fixes spelling error<commit_after>/*
Copyright 2017 Toolhouse, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

	http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main

import (
	"encoding/json"
	"fmt"
	"net/http"
	"os"
	"strings"

	"github.com/hashicorp/go-multierror"
	"github.com/pkg/errors"
)

// The following environment variables are required for this script
const (
	URL    = "URL"
	COMMIT = "COMMIT"
	REF    = "REF"
)

// DeploymentManifest defines the JSON schema for a deployment manifest file
type DeploymentManifest struct {
	Commit string `json:"commit"`
	Ref    string `json:"ref"`
}

func main() {
	c, err := configFromEnv()
	if err != nil {
		os.Stderr.WriteString("Configuration issue: ")
		os.Stderr.WriteString(err.Error())
		os.Stderr.WriteString("\n")
		os.Exit(1)
	}

	err = verify(c.URL, c.Commit, c.Ref)
	if err != nil {
		os.Stderr.WriteString("Issue verifying deployment: ")
		os.Stderr.WriteString(err.Error())
		os.Stderr.WriteString("\n")
		os.Exit(1)
	}

	fmt.Println("Deployment verified")
	os.Exit(0)
}

func verify(url, commit, ref string) error {
	res, err := http.Get(url)
	if err != nil {
		return errors.Wrap(err, "Error fetching deployment manifest JSON")
	}

	if res.StatusCode < 200 || res.StatusCode > 299 {
		return errors.Errorf("Received non-200 HTTP status code: %s", res.Status)
	}

	defer res.Body.Close()
{'fraction_non_alphanumeric': 0.11685770198490356, 'fraction_numerical': 0.01118255521386637, 'mean_word_length': 4.032348804500703, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7398567', 'n_tokens_mistral': 1207, 'n_tokens_neox': 1147, 'n_words': 383}