-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
newadmin: add command for changing git source of truth config
Summary: Adds a newadmin command `git-source-of-truth set` for displaying changing the git source of truth config for a repo. Reviewed By: RajivTS Differential Revision: D61920226 fbshipit-source-id: 1a958bea2649f8240fff3d3397a07e857e665058
- Loading branch information
1 parent
74d5b75
commit ed24fc7
Showing
3 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
eden/mononoke/tests/integration/newadmin/test-newadmin-git-source-of-truth.t
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# | ||
# This software may be used and distributed according to the terms of the | ||
# GNU General Public License found in the LICENSE file in the root | ||
# directory of this source tree. | ||
|
||
$ . "${TEST_FIXTURES}/library.sh" | ||
|
||
setup configuration | ||
$ setup_common_config | ||
|
||
$ mononoke_newadmin git-source-of-truth -R repo show | ||
No git source of truth config entry found for repo repo | ||
|
||
$ mononoke_newadmin git-source-of-truth -R repo set locked | ||
|
||
$ mononoke_newadmin git-source-of-truth -R repo show | ||
GitSourceOfTruthConfigEntry { id: RowId(1), repo_id: RepositoryId(0), repo_name: RepositoryName("repo"), source_of_truth: Locked } | ||
|
||
$ mononoke_newadmin git-source-of-truth -R repo set mononoke | ||
|
||
$ mononoke_newadmin git-source-of-truth -R repo show | ||
GitSourceOfTruthConfigEntry { id: RowId(2), repo_id: RepositoryId(0), repo_name: RepositoryName("repo"), source_of_truth: Mononoke } | ||
|
||
$ mononoke_newadmin git-source-of-truth -R repo set metagit | ||
|
||
$ mononoke_newadmin git-source-of-truth -R repo show | ||
GitSourceOfTruthConfigEntry { id: RowId(3), repo_id: RepositoryId(0), repo_name: RepositoryName("repo"), source_of_truth: Metagit } |
This file contains 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
39 changes: 39 additions & 0 deletions
39
eden/mononoke/tools/admin/src/commands/git_source_of_truth/set.rs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This software may be used and distributed according to the terms of the | ||
* GNU General Public License version 2. | ||
*/ | ||
|
||
use anyhow::Result; | ||
use clap::builder::PossibleValuesParser; | ||
use clap::Args; | ||
use context::CoreContext; | ||
use git_source_of_truth::GitSourceOfTruth; | ||
use git_source_of_truth::GitSourceOfTruthConfigRef; | ||
use git_source_of_truth::RepositoryName; | ||
use repo_identity::RepoIdentityRef; | ||
|
||
use super::Repo; | ||
|
||
#[derive(Args)] | ||
pub struct SetArgs { | ||
/// Source of truth to set for this repo. [possible values: metagit, mononoke, locked] | ||
source_of_truth: GitSourceOfTruth, | ||
} | ||
|
||
pub async fn set(ctx: &CoreContext, repo: &Repo, args: SetArgs) -> Result<()> { | ||
let repo_id = repo.repo_identity().id(); | ||
let repo_name = repo.repo_identity().name(); | ||
|
||
repo.git_source_of_truth_config() | ||
.set( | ||
ctx, | ||
repo_id, | ||
RepositoryName(repo_name.to_string()), | ||
args.source_of_truth, | ||
) | ||
.await?; | ||
|
||
Ok(()) | ||
} |