ADDED checks for other manifest items

This commit is contained in:
Ewan Valentine 2017-04-13 22:45:32 +01:00
Родитель 6baa37b535
Коммит 8f0af4696c
4 изменённых файлов: 28 добавлений и 7 удалений

Просмотреть файл

@ -0,0 +1,7 @@
# Example:
# [[dependencies]]
# branch = "master"
# name = "github.com/vendor/package"
# revision = "abc123"
# version = "1.0.0"

Просмотреть файл

@ -0,0 +1,7 @@
# Example:
# [[dependencies]]
# branch = "master"
# name = "github.com/vendor/package"
# revision = "abc123"
# version = "1.0.0"

Просмотреть файл

@ -140,6 +140,14 @@ func (m *Manifest) toRaw() rawManifest {
return raw
}
// IsEmpty - Checks if payload is empty
func (m *Manifest) IsEmpty() bool {
if m.Ovr == nil && len(m.Ignores) == 0 && len(m.Dependencies) == 0 {
return true
}
return false
}
type sortedRawProjects []rawProject
func (s sortedRawProjects) Len() int { return len(s) }

Просмотреть файл

@ -27,6 +27,8 @@ const exampleToml = `
# [[dependencies]]
# branch = "master"
# name = "github.com/vendor/package"
# revision = "abc123"
# version = "1.0.0"
`
// SafeWriter transactionalizes writes of manifest, lock, and vendor dir, both
@ -264,6 +266,10 @@ func (sw *SafeWriter) Write(root string, sm gps.SourceManager) error {
defer os.RemoveAll(td)
if sw.Payload.HasManifest() {
if sw.Payload.Manifest.IsEmpty() {
err := modifyWithString(mpath, exampleToml)
return errors.Wrap(err, "failed to generate example text")
}
if err := writeFile(filepath.Join(td, ManifestName), sw.Payload.Manifest); err != nil {
return errors.Wrap(err, "failed to write manifest file to temp dir")
}
@ -361,13 +367,6 @@ func (sw *SafeWriter) Write(root string, sm gps.SourceManager) error {
os.RemoveAll(vendorbak)
}
if len(sw.Payload.Manifest.Dependencies) == 0 {
err := modifyWithString(mpath, exampleToml)
if err != nil {
goto fail
}
}
return nil
fail: