Skip to content

Conversation

mikeland73
Copy link
Contributor

@mikeland73 mikeland73 commented May 29, 2023

Summary

This implements devbox global pull <git> and offers familiar --force flag to overwrite conflicts.

Existing functionality change:

It also changes the behavior of existing pull <url> and pull <local-path> to also warn and overwrite on --force instead of merging. We do this to standardize behavior.

How was it tested?

devbox global pull git@github.com:mikeland86/global.git
devbox global pull https://fleekgen.fly.dev/high --force
devbox global pull devbox.json --force
devbox global pull https://raw.githubusercontent.com/mikeland86/global/main/devbox.json\?token=<token>

@mikeland73 mikeland73 requested review from gcurtis and savil May 29, 2023 22:41

cmd.Flags().BoolVarP(
&flags.force, "force", "f", false,
"Force overwrite of existing global config files",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drop global and make singular file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do. I've been adding [global] to indicate optionality.

Comment on lines 51 to 54
path, err := ensureGlobalConfig(cmd)
if err != nil {
return errors.WithStack(err)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how should we refactor this call so that it is applicable to non-global use-case as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be here, global parent command already does this. Will remove.

return errors.WithStack(err)
}

err = box.PullGlobal(cmd.Context(), overwrite, pullPath)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets rename PullGlobal to just Pull

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, was on my todo.

@mikeland73
Copy link
Contributor Author

@savil FYI, the implementation changed a bit (now simpler). We don't create git repos, we just copy the content to avoid keeping any state.

@mikeland73 mikeland73 merged commit b926a8c into main May 31, 2023
@mikeland73 mikeland73 deleted the landau/pull-git branch May 31, 2023 23:04
mikeland73 added a commit that referenced this pull request Jun 1, 2023
## Summary

Stacked on #1061

This allows users to push global config (and any other files) to a repo.
Pushing applies the current global profile on top of the latest commit
in the repo (clone, commit, and push). It does not require force because
it always applies on the latest commit.

## How was it tested?

```bash
devbox global pull git@github.com:mikeland86/global.git
devbox global push git@github.com:mikeland86/global.git
devbox global add curl
devbox global push git@github.com:mikeland86/global.git
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants