-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disallow re-initialization with differen value of --with-forks #196
Conversation
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.
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 <[email protected]>
@@ -114,7 +159,7 @@ type envFile struct { | |||
WithForks bool | |||
} | |||
|
|||
func (f *envFile) String() string { | |||
func (f *envFile) MarshalEnv() ([]byte, error) { |
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.
why not simply Marshal
/Unmarshal
?
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.
To be in line with std lib and other serialization libs.
} | ||
|
||
line := strings.SplitN(scanner.Text(), "=", 2) | ||
value := line[1] |
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.
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...
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.
fixed by skipping lines without =
, thanks
Signed-off-by: Maxim Sukharev <[email protected]>
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: