func fakeUpdater(versionUpdates []VersionUpdate, orgDepFiles, uptDepFiles *[]models.DependencyFile) error {
	f := models.DependencyFile{Path: "Gemfile.lock", SHA: "09c2f8647e14e49e922b955c194102070597c2d1", Content: []byte("original content")}
	*orgDepFiles = append(*orgDepFiles, f)
	f.Content = []byte("updated content")
	f.SHA = "141162477fd3bf27aed3bbea4fe3d17c71d6c7be"
	*uptDepFiles = append(*uptDepFiles, f)
	return nil
}
func fakeInstaller(reqUpdates []RequirementUpdate, orgDepFiles, uptDepFiles *[]models.DependencyFile) error {
	for _, ru := range reqUpdates {
		var f models.DependencyFile = ru.File
		f.Content = []byte("original content")
		*orgDepFiles = append(*orgDepFiles, f)
		fmt.Println("Patching", f.Path)
		f.Content = []byte("New content")
		*uptDepFiles = append(*uptDepFiles, f)
	}
	return nil
}
Exemple #3
0
// Should be common to other updaters
func PatchFile(ru RequirementUpdate, orgDepFiles, uptDepFiles *[]models.DependencyFile) error {
	var f models.DependencyFile = ru.File
	err := f.CheckFileSHA1()
	if err != nil {
		return err
	}
	// fetch file content
	f.Update()
	*orgDepFiles = append(*orgDepFiles, f)
	fmt.Println("Patching", f.Path)
	err = f.Patch(ru.Patch)
	if err != nil {
		return err
	}
	*uptDepFiles = append(*uptDepFiles, f)
	return nil
}