func DependencyFilePatch(df *api.DependencyFile, patch string) error {
	patchPath, err := exec.LookPath("patch")
	if err != nil {
		return err
	}
	cmd := exec.Command(patchPath, df.Path)
	stdin, err := cmd.StdinPipe()
	if err != nil {
		return err
	}
	stdout, err := cmd.StdoutPipe()
	if err != nil {
		return err
	}
	if err = cmd.Start(); err != nil {
		return err
	}
	_, err = io.WriteString(stdin, patch)
	if err != nil {
		return err
	}
	stdin.Close()
	out, err := ioutil.ReadAll(stdout)
	if err != nil {
		return err
	}
	if err = cmd.Wait(); err != nil {
		fmt.Println(string(out))
		return err
	}
	err = DependencyFileUpdate(df)
	if err != nil {
		return err
	}
	return nil
}
Apply patch to the file referenced by Path
If Content is empty, the file content is read from the file directly
package dependency
import (
	"bytes"
	"crypto/sha1"
	"encoding/base64"
	"fmt"
	"io"
	"io/ioutil"
	"os"
	"os/exec"
	"path/filepath"
	"strings"
	"github.com/gemnasium/depfile"
	"github.com/gemnasium/toolbelt/api"
	"github.com/gemnasium/toolbelt/config"
	"github.com/gemnasium/toolbelt/project"
	"github.com/olekukonko/tablewriter"
)
func NewDependencyFile(filePath string) *api.DependencyFile {
	content, err := ioutil.ReadFile(filePath)
	if err != nil {
		return nil
	}
	sha, err := GetFileSHA1(filePath)
	if err != nil {
		return nil
	}
	return &api.DependencyFile{Path: filePath, SHA: sha, Content: content}
}
func DependencyFileCheckFileSHA1(df *api.DependencyFile) error {
	sum, err := GetFileSHA1(df.Path)
	if err != nil {
		return err
	}
	if sum != df.SHA {
		return fmt.Errorf("%s: File signature doesn't match (expected: %s, got: %s)", df.Path, df.SHA, sum)
	}
	return nil
}
func DependencyFileUpdateSHA(df *api.DependencyFile) error {
	sha, err := GetFileSHA1(df.Path)
	if err != nil {
		return err
	}
	df.SHA = sha
	return nil
}
func DependencyFileUpdate(df *api.DependencyFile) error {
	content, err := ioutil.ReadFile(df.Path)
	if err != nil {
		return err
	}
	df.Content = content
	err = DependencyFileUpdateSHA(df)
	if err != nil {
		return err
	}
	return nil
}