-
Notifications
You must be signed in to change notification settings - Fork 321
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* First commit that just sets up scaffolding. * `jj git sync` is hidden as it's not yet ready. Issue: #1039
- Loading branch information
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
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
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,48 @@ | ||
use crate::cli_util::CommandHelper; | ||
use crate::ui::Ui; | ||
/// Sync the local JJ repo to specified Git remote branch(es). | ||
/// | ||
/// The sync command will first fetch from the Git remote, then | ||
/// rebase all local changes onto the appropriate updated | ||
/// heads that were fetched. | ||
/// | ||
/// Changes that are made empty by the rebase are dropped. | ||
#[derive(clap::Args, Clone, Debug)] | ||
pub struct GitSyncArgs { | ||
/// Rebase only the specified branches. | ||
/// | ||
/// Note that this value affects only the rebase behaviour, as | ||
/// the fetch behaviour always fetches all branches. | ||
/// | ||
/// By default, the specified name matches exactly. Use `glob:` prefix to | ||
/// expand `*` as a glob. The other wildcard characters aren't supported. | ||
#[arg(long, short, alias="bookmark", default_value = "glob:*", value_parser = StringPattern::parse)] | ||
pub branch: Vec<StringPattern>, | ||
/// Fetch from all remotes | ||
/// | ||
/// By default, the fetch will only use remotes configured in the `git.fetch` | ||
/// section of the config. | ||
/// | ||
/// When specified, --all-remotes causes the fetch to use all remotes known | ||
/// to the underlying git repo. | ||
#[arg(long, default_value = "false")] | ||
pub all_remotes: bool, | ||
} | ||
|
||
pub fn cmd_git_sync( | ||
ui: &mut Ui, | ||
command: &CommandHelper, | ||
args: &GitSyncArgs, | ||
) -> Result<(), CommandError> { | ||
let mut workspace_command = command.workspace_helper(ui)?; | ||
let guard = tracing::debug_span!("git.sync.pre-fetch").entered(); | ||
drop(guard); | ||
let guard = tracing::debug_span!("git.sync.fetch").entered(); | ||
drop(guard); | ||
let guard = tracing::debug_span!("git.sync.post-fetch").entered(); | ||
drop(guard); | ||
let guard = tracing::debug_span!("git.sync.rebase").entered(); | ||
drop(guard); | ||
|
||
Ok(()) | ||
} |