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

ReposVerb: allow registering vanilla Git repos #258

Closed
wants to merge 23 commits into from
Closed

ReposVerb: allow registering vanilla Git repos #258

wants to merge 23 commits into from

Conversation

derrickstolee
Copy link
Contributor

@derrickstolee derrickstolee commented Dec 10, 2019

Part of #254 and half of #214. Resolves #252.

The scalar repos verb allows two modes:

  1. scalar repos add: add the current enlistment to the list being watched by the Scalar service.
  2. scalar repos list: list the current set of enlistments being watched by the Scalar service.

scalar repos add inside a Scalar or Git repository will register the repo with the Scalar service. The service will start running maintenance on that repo.

The way we identify a vanilla Git repo (now) is if the object cache dir is not given by config and hence we do all operations on the local .git folder. This will not work with Git worktrees, but we will also not discover a .git folder (worktrees use a .git file) so the enlistment will be invalid.

  • The commit-graph task will generate the incremental commit-graph files using the --reachable option. This will be a no-op if the user has not changed their refs.

  • The packfile task will write a multi-pack-index and do the expire/repack logic. To actually do something, the batch-size is decreased if the total pack size is smaller than 2gb.

  • The loose-objects task will delete loose objects already in pack-files and put them into a new from-loose pack.

  • The fetch-commits-and-trees task is renamed the fetch task. On a vanilla Git repo, it will simply call git fetch origin --no-update-remote-refs +refs/head/*:refs/hidden/*. This downloads a pack-file with the new objects not reachable form the current refs, but also does not update refs/remotes/. The user will see their refs update as normal, but the pack download is much smaller.

  • The new config task runs the necessary Git config. This step is run at clone and add time, but also in the background with the service. Some config options are removed as required for vanilla Git repos.

@derrickstolee derrickstolee added this to the EA milestone Dec 10, 2019
@derrickstolee derrickstolee changed the title [RFC] WatchVerb: allow watching vanilla Git repos WatchVerb: allow watching vanilla Git repos Dec 13, 2019
@derrickstolee derrickstolee marked this pull request as ready for review December 13, 2019 19:32
@derrickstolee derrickstolee changed the title WatchVerb: allow watching vanilla Git repos ReposVerb: allow registering vanilla Git repos Dec 16, 2019
Copy link
Member

@jrbriggs jrbriggs left a comment

Choose a reason for hiding this comment

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

Looking good, some minor suggestions.

Scalar.Common/ScalarConstants.cs Outdated Show resolved Hide resolved
Scalar.Common/ScalarEnlistment.cs Outdated Show resolved Hide resolved
Scalar/CommandLine/ReposVerb.cs Outdated Show resolved Hide resolved
Scalar/CommandLine/ReposVerb.cs Outdated Show resolved Hide resolved
Scalar/CommandLine/ReposVerb.cs Outdated Show resolved Hide resolved
docs/commands/scalar-repos.md Outdated Show resolved Hide resolved
docs/commands/scalar-repos.md Outdated Show resolved Hide resolved
docs/commands/scalar-repos.md Show resolved Hide resolved
@microsoft microsoft deleted a comment from azure-pipelines bot Dec 17, 2019
@microsoft microsoft deleted a comment from azure-pipelines bot Dec 17, 2019
@derrickstolee derrickstolee changed the title ReposVerb: allow registering vanilla Git repos [WIP] ReposVerb: allow registering vanilla Git repos Dec 17, 2019
@derrickstolee
Copy link
Contributor Author

@jrbriggs: Thanks for the feedback. I'll respond to that soon.

I'm marking this PR as WIP for the remainder of the holidays. I'm going to go a bit nuts adding stuff to this PR until I feel I have a "complete" picture of the feature. Then, we can split it into smaller pieces for review when people have bandwidth.

derrickstolee and others added 11 commits December 20, 2019 13:12
Signed-off-by: Derrick Stolee <stolee@gmail.com>
This also allows re-registering Scalar repos if they somehow become
unregistered. (We will follow-up with a way to un-watch later.)

The only required update to the maintenance steps right now is to
make the fetch-commits-and-trees step be a no-op for non-Scalar
repos. Eventually, we will want that to run a "git fetch" (in a
way that does not update the refs/remotes space).

Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Derrick Stolee <stolee@gmail.com>
When we run functional tests inside the Scalar source code, we
need our vanilla Git repos to be recognized inside that repo. The
old logic would look for "src/.git" first, finding the Scalar repo
before looking just for ".git". This makes the code simpler, too!

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
@derrickstolee derrickstolee changed the title [WIP] ReposVerb: allow registering vanilla Git repos ReposVerb: allow registering vanilla Git repos Dec 20, 2019
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
derrickstolee and others added 7 commits December 20, 2019 16:28
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Derrick Stolee <stolee@gmail.com>
derrickstolee added a commit that referenced this pull request Jan 2, 2020
These commits are cherry-picked from #258 with slight modifications. The functionality here makes sense for repos cloned by Scalar, allowing us to focus later on the interactions with vanilla Git repos.

1. Add `ConfigStep` for running the Git config commands at clone time and as the service starts up. This already has some split for vanilla Git repos, but that code does not get exercised. Resolves #252.
2. The `PackfileMaintenanceStep` attempts to repack all but the largest pack when those packs sum to less than 2gb.
3. Some cleanup things here and there.
4. `scalar repos (add|list)` allows tracking the registered repos. Resolves some of #214.
derrickstolee added a commit that referenced this pull request Jan 8, 2020
Replaces #258. Resolves #254.

If you have a "vanilla" Git repo, then run `scalar repos add` in that repo. Scalar will detect the repo root, register that root with the service, and the maintenance steps will run.

The way we identify a vanilla Git repo (now) is if the object cache dir is not given by config and hence we do all operations on the local `.git` folder. This will not work with Git worktrees, but we will also not discover a `.git` _folder_ (worktrees use a `.git` _file_) so the enlistment will be invalid.

* The `commit-graph` task will generate the incremental commit-graph files using the `--reachable` option. This will be a no-op if the user has not changed their refs.

* The `packfile` task will write a `multi-pack-index` and do the expire/repack logic. To actually do something, the batch-size is decreased if the total pack size is smaller than 2gb. (This was done in #272.)

* The `loose-objects` task will delete loose objects already in pack-files and put them into a new `from-loose` pack. This required no change.

* The `fetch-commits-and-trees` task is renamed the `fetch` task. On a vanilla Git repo, it will simply call `git fetch <remote> --no-update-remote-refs +refs/head/*:refs/hidden/<remote>/*` for each `<remote>` given by `git remote`. This downloads a pack-file with the new objects not reachable form the current refs, but also does not update `refs/remotes/`. The user will see their refs update as normal, but the pack download is much smaller.

* The `config` task (added by #272) runs the necessary Git config.  This step is run in `scalar repos add`, but also in the background with the service. All config options become optional for vanilla Git repos, so a user can opt-out of the settings we recommend.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a config maintenance step
2 participants