ADDED example comment to toml file on init #343 #374
Changes from 1 commit
6baa37b
8f0af46
8d594bf
3147848
0c6c997
6bdf324
c1aa041
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,16 @@ import ( | |
"github.com/sdboyer/gps" | ||
) | ||
|
||
// Example string to be written to the manifest file | ||
// if no dependencies are found in the project | ||
// during `dep init` | ||
const exampleToml = ` | ||
# Example: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add the remaining available options, |
||
# [[dependencies]] | ||
# branch = "master" | ||
# name = "github.com/vendor/package" | ||
` | ||
|
||
// SafeWriter transactionalizes writes of manifest, lock, and vendor dir, both | ||
// individually and in any combination, into a pseudo-atomic action with | ||
// transactional rollback. | ||
|
@@ -172,6 +182,7 @@ const ( | |
// - If oldLock is provided without newLock, error. | ||
// - If vendor is VendorAlways without a newLock, error. | ||
func (sw *SafeWriter) Prepare(manifest *Manifest, oldLock, newLock *Lock, vendor VendorBehavior) error { | ||
|
||
sw.Payload = &SafeWriterPayload{ | ||
Manifest: manifest, | ||
Lock: newLock, | ||
|
@@ -227,6 +238,7 @@ func (payload SafeWriterPayload) validate(root string, sm gps.SourceManager) err | |
// This mostly guarantees that dep cannot exit with a partial write that would | ||
// leave an undefined state on disk. | ||
func (sw *SafeWriter) Write(root string, sm gps.SourceManager) error { | ||
|
||
if sw.Payload == nil { | ||
return errors.New("Cannot call SafeWriter.Write before SafeWriter.Prepare") | ||
} | ||
|
@@ -349,6 +361,13 @@ func (sw *SafeWriter) Write(root string, sm gps.SourceManager) error { | |
os.RemoveAll(vendorbak) | ||
} | ||
|
||
if len(sw.Payload.Manifest.Dependencies) == 0 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the goal is to only print out the example help text when the manifest is empty, then you will also need to test the manifest's There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I looked into the nil pointer error from the build and it is because the If you move this check under the |
||
err := modifyWithString(mpath, exampleToml) | ||
if err != nil { | ||
goto fail | ||
} | ||
} | ||
|
||
return nil | ||
|
||
fail: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: s/modifyWithString - Modifies/modifyWithString modifies/
Just slightly more standard practice for docblocks.