Skip to content
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

git-bundle-server CLI Part 2: collapse base bundle and the update-all subcommand #3

Merged
merged 6 commits into from
Sep 21, 2022

Conversation

derrickstolee
Copy link
Collaborator

Based on #2.

The update subcommand now notices when there are more than 5 bundles and squashes the oldest ones into a new "base" bundle. The bundle is renamed but keeps the maximum creation token from that group of bundles.

Modified some of the parameters, especially those in the git package to avoid cyclic package dependencies. Also used struct pointers more often.

Repository routes are now stored in a new routes file (currently plaintext with line-separated list of routes).

The new update-all subcommand runs the update subcommand on all registered routes. It also passes any remaining arguments down to the subcommand, which will help when we add the --daily and --hourly options.

@derrickstolee derrickstolee self-assigned this Aug 24, 2022
Copy link

@dscho dscho left a comment

Choose a reason for hiding this comment

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

Again, with the caveat that I am not actively using Go, this looks good, in particular the places where a missing err handling was introduced.

One thing I always find particularly invaluable when developing software quickly is a set of automated tests. Do you think it would make sense to start this soon, or would it rather slow you down at this stage?

@derrickstolee
Copy link
Collaborator Author

derrickstolee commented Aug 25, 2022

One thing I always find particularly invaluable when developing software quickly is a set of automated tests. Do you think it would make sense to start this soon, or would it rather slow you down at this stage?

As I'm building the features, I'm benefitting from the fact that every method prototype can be changed quickly. I have some end-to-end scripts that allow me to manually check that things are working as I expect, but until I have a more complete view of things I'll need to hold off on a test suite. In the (internal) tracking issue I have an item for creating a test strategy after we reach a prototype that can be used for evaluation.

@derrickstolee derrickstolee changed the base branch from stolee/cli-1 to main August 25, 2022 15:18
@derrickstolee
Copy link
Collaborator Author

derrickstolee commented Aug 25, 2022

One thing I always find particularly invaluable when developing software quickly is a set of automated tests. Do you think it would make sense to start this soon, or would it rather slow you down at this stage?

As I'm building the features, I'm benefitting from the fact that every method prototype can be changed quickly. I have some end-to-end scripts that allow me to manually check that things are working as I expect, but until I have a more complete view of things I'll need to hold off on a test suite. In the (internal) tracking issue I have an item for creating a test strategy after we reach a prototype that can be used for evaluation.

All of that said, I've been playing around with getting automated builds so at least we get compiler checks as PRs are going in. However, I continue to struggle with Go's build environment and package rules. Work is ongoing in the stolee/cli-3 branch.

Copy link

@dscho dscho left a comment

Choose a reason for hiding this comment

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

These changes look simple enough that even I understand them, in particular with the help of the excellent commit messages. Thank you!

A last-minute replacement of parsing to use scanner.Scan() changed the
newline behavior of the line reading. This change allows us to actually
parse bundle headers.
@derrickstolee derrickstolee force-pushed the stolee/cli-2 branch 2 times, most recently from 952a771 to 60195e1 Compare August 30, 2022 14:49
Copy link
Collaborator

@mjcheetham mjcheetham left a comment

Choose a reason for hiding this comment

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

Looks good! Added some non-blocking comments

internal/core/repo.go Show resolved Hide resolved
"os/exec"
)

type UpdateAll struct{}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know I mentioned this offline, but mentioning it here too..

Having update-all as a separate subcommand that calls out to update in a loop will mean paying some cost to fork+exec, and possibly and other process setup, config, tracing etc.

Would the update --all loop being in the same subcommand (or even update-all that leverages the same update functions in a loop) not be preferable here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think for now, the fact that <route> is a positional argument in the CLI makes me not want to swap this. Keep in mind that we are also spawning git fetch subcommands at minimum and git bundle create if there is new data, so the process startup cost is very small compared to what commands we are running under the hood.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've attempted the rewrite of update-all as update --all in this branch, but I'm again having local build issues (:old-man-shakes-fist-at-go:).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Of course the build issues come from the fact that I removed the go.work workspace file and all of the go.mod files throughout my workspace. So... they are somehow critical to how I was able to get things working.

internal/bundles/bundles.go Outdated Show resolved Hide resolved
This constant of "5" will one day be replaced with a configurable value
whose default is probably "30". It has other issues when we add the
concept of "daily" and "hourly" bundles.

For now, 5 is sufficient. Convert the oldest bundles together into a
single bundle, now called "base-<token>.bundle". We need to be careful
when defining the refs to use for each of these tips, so create a new
'refs/base/' ref namespace. Some TODOs are marked to use 'git merge-base
--independent' to reduce the number of tips used by this base bundle.

We need to be careful, but it is possible that we could also "GC" the
base bundle if the tip commits are not reachable from any tips in the
later bundles. In such a case, we might need to rebuild all of those
bundles to ensure that the REF_DELTA bases exist as needed (perhaps this
is part of the prereq commits, so it might not be a real worry).
The routes file stores the list of known routes. These correspond to
directories in the repo root and web root.

While here, update our use of core.Repository to be pointer-based.
The 'update-all' subcommand runs the 'update' subcommand on all
registered routes.
We will later add --daily and --hourly arguments to the 'update'
subcommand, but for now we will blindly pass the arguments down.
@derrickstolee derrickstolee merged commit b10b284 into main Sep 21, 2022
@vdye vdye deleted the stolee/cli-2 branch May 3, 2023 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants