Disallow re-initialization with differen value of --with-forks#196
Merged
smacker merged 2 commits intosrc-d:masterfrom Aug 8, 2019
smacker:disallow_forks_flag_switch
Merged
Disallow re-initialization with differen value of --with-forks#196smacker merged 2 commits intosrc-d:masterfrom smacker:disallow_forks_flag_switch
smacker merged 2 commits intosrc-d:masterfrom
smacker:disallow_forks_flag_switch
Conversation
dpordomingo
approved these changes
Aug 7, 2019
Contributor
dpordomingo
left a comment
There was a problem hiding this comment.
LGTM
I didn't perform a really deeeeep review but I like the idea and code.
- Switching --with-forks flag for already initialized working directory is unsupported because gitcollector/ghsync can't delete data. Also user might have some pre-computed data that would cause charts to fail if forks are removed. The only safe way to switch the flag is to prune and recreate. Automatic prune might be very unexpected for a user so it shows an error and asks the user to run prune manually. - Implement envFile decoder, it will be useful for showing status later as well Example of the error when an org was already initialized without forks: ``` $ go run cmd/sourced/main.go init orgs golang-migrate --with-forks initialization failed: workdir was previously initialized with a different value for forks support Cannot perform this action, full re-initialization is needed, run 'prune' command first exit status 1 ``` Signed-off-by: Maxim Sukharev <max@smacker.ru>
carlosms
reviewed
Aug 8, 2019
| } | ||
|
|
||
| func (f *envFile) String() string { | ||
| func (f *envFile) MarshalEnv() ([]byte, error) { |
Contributor
There was a problem hiding this comment.
why not simply Marshal/Unmarshal?
Contributor
Author
There was a problem hiding this comment.
To be in line with std lib and other serialization libs.
| } | ||
|
|
||
| line := strings.SplitN(scanner.Text(), "=", 2) | ||
| value := line[1] |
Contributor
There was a problem hiding this comment.
I think we should check the length of line.
A line like # A comment will panic.
It should not fail with the current contents, but just in case we may change the contents later, or a user may edit this manually...
Contributor
Author
There was a problem hiding this comment.
fixed by skipping lines without =, thanks
Signed-off-by: Maxim Sukharev <max@smacker.ru>
carlosms
approved these changes
Aug 8, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #109 (we have a separate issue for status command now)
Switching --with-forks flag for already initialized working directory
is unsupported because gitcollector/ghsync can't delete data. Also user
might have some pre-computed data that would cause charts to fail if
forks are removed. The only safe way to switch the flag is to prune and
recreate. Automatic prune might be very unexpected for a user so it
shows an error and asks the user to run prune manually.
Implement envFile decoder, it will be useful for showing status later
as well
Example of the error when an org was already initialized without forks: