Skip to content

feat(sync): when --pull is passed, fetch only from the main branch remote, instead of all remotes #1364

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
10 changes: 1 addition & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion git-branchless-invoke/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ version = "0.10.0"
[dependencies]
clap = { workspace = true, features = ["derive"] }
color-eyre = { workspace = true }
cursive_core = { workspace = true }
eyre = { workspace = true }
git-branchless-opts = { workspace = true }
git2 = { workspace = true }
Expand Down
4 changes: 1 addition & 3 deletions git-branchless-invoke/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@ use std::path::PathBuf;
use std::time::SystemTime;

use clap::{CommandFactory, FromArgMatches, Parser};
use cursive_core::theme::BaseColor;
use cursive_core::utils::markup::StyledString;
use eyre::Context;
use git_branchless_opts::{ColorSetting, GlobalArgs};
use lib::core::config::env_vars::{get_git_exec_path, get_path_to_git};
use lib::core::effects::Effects;
use lib::core::formatting::Glyphs;
use lib::core::formatting::{BaseColor, Glyphs, StyledString};
use lib::git::GitRunInfo;
use lib::git::{Repo, RepoError};
use lib::util::{ExitCode, EyreExitOr};
Expand Down
2 changes: 1 addition & 1 deletion git-branchless-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ chrono = { workspace = true }
color-eyre = { workspace = true }
concolor = { workspace = true }
console = { workspace = true }
cursive = { workspace = true }
cursive_core = { workspace = true }
eden_dag = { workspace = true }
eyre = { workspace = true }
futures = { workspace = true }
Expand Down
3 changes: 1 addition & 2 deletions git-branchless-lib/src/core/check_out.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ use std::ffi::{OsStr, OsString};
use std::fmt::Write;
use std::time::{SystemTime, UNIX_EPOCH};

use cursive::theme::BaseColor;
use cursive::utils::markup::StyledString;
use eyre::Context;
use itertools::Itertools;
use tracing::instrument;

use crate::core::config::get_auto_switch_branches;
use crate::core::formatting::{BaseColor, StyledString};
use crate::git::{
update_index, CategorizedReferenceName, GitRunInfo, MaybeZeroOid, NonZeroOid, ReferenceName,
Repo, Stage, UpdateIndexCommand, WorkingCopySnapshot,
Expand Down
4 changes: 1 addition & 3 deletions git-branchless-lib/src/core/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ use std::ffi::OsString;
use std::fmt::Write;
use std::path::PathBuf;

use cursive::theme::{BaseColor, Effect, Style};
use cursive::utils::markup::StyledString;
use eyre::Context;
use tracing::{instrument, warn};

use crate::core::formatting::StyledStringBuilder;
use crate::core::formatting::{BaseColor, Effect, Style, StyledString, StyledStringBuilder};
use crate::git::{ConfigRead, GitRunInfo, GitRunOpts, Repo};

use super::effects::Effects;
Expand Down
1 change: 0 additions & 1 deletion git-branchless-lib/src/core/eventlog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,6 @@ INSERT INTO event_log VALUES (
///
/// Returns: All the events in the database, ordered from oldest to newest.
#[instrument]

pub fn get_events(&self) -> eyre::Result<Vec<Event>> {
let mut stmt = self.conn.prepare(
"
Expand Down
7 changes: 3 additions & 4 deletions git-branchless-lib/src/core/formatting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

use std::fmt::Display;

use cursive::theme::{Effect, Style};
use cursive::utils::markup::StyledString;
use cursive::utils::span::Span;
pub use cursive_core::theme::{BaseColor, Color, ColorType, Effect, Style};
pub use cursive_core::utils::markup::StyledString;
pub use cursive_core::utils::span::Span;

/// Pluralize a quantity, as appropriate. Example:
///
Expand Down Expand Up @@ -369,7 +369,6 @@ fn render_style_as_ansi(content: &str, style: Style) -> eyre::Result<String> {
let Style { effects, color } = style;
let output = {
use console::style;
use cursive::theme::{BaseColor, Color, ColorType};
let output = content.to_string();
match color.front {
ColorType::Palette(_) => {
Expand Down
12 changes: 5 additions & 7 deletions git-branchless-lib/src/core/node_descriptors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ use std::sync::{Arc, Mutex};
use std::time::SystemTime;

use bstr::{ByteSlice, ByteVec};
use cursive::theme::BaseColor;
use cursive::utils::markup::StyledString;
use lazy_static::lazy_static;
use regex::Regex;
use tracing::instrument;
Expand All @@ -18,15 +16,15 @@ use crate::core::config::{
get_commit_descriptors_branches, get_commit_descriptors_differential_revision,
get_commit_descriptors_relative_time,
};
use crate::core::eventlog::{Event, EventCursor, EventReplayer};
use crate::core::formatting::Glyphs;
use crate::core::formatting::{BaseColor, StyledString, StyledStringBuilder};
use crate::core::repo_ext::RepoReferencesSnapshot;
use crate::core::rewrite::find_rewrite_target;
use crate::git::{
CategorizedReferenceName, Commit, NonZeroOid, ReferenceName, Repo, ResolvedReferenceInfo,
};

use super::eventlog::{Event, EventCursor, EventReplayer};
use super::formatting::{Glyphs, StyledStringBuilder};
use super::repo_ext::RepoReferencesSnapshot;
use super::rewrite::find_rewrite_target;

/// An object which can be rendered in the smartlog.
#[derive(Clone, Debug)]
pub enum NodeObject<'repo> {
Expand Down
4 changes: 1 addition & 3 deletions git-branchless-lib/src/git/object.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
use std::path::Path;

use bstr::{BString, ByteSlice};
use cursive::theme::BaseColor;
use cursive::utils::markup::StyledString;
use git2::message_trailers_bytes;
use tracing::instrument;

use crate::core::formatting::{Glyphs, StyledStringBuilder};
use crate::core::formatting::{BaseColor, Glyphs, StyledString, StyledStringBuilder};
use crate::core::node_descriptors::{
render_node_descriptors, CommitMessageDescriptor, CommitOidDescriptor, NodeObject, Redactor,
};
Expand Down
13 changes: 13 additions & 0 deletions git-branchless-lib/src/git/reference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,19 @@ impl<'repo> Branch<'repo> {
Ok(Some(upstream_branch_name_without_remote.to_owned()))
}

/// Get the associated remote to pull from for this branch. If there is no
/// associated remote, returns `None`.
#[instrument]
pub fn get_pull_remote_name(&self) -> eyre::Result<Option<String>> {
let branch_name = self
.inner
.name()?
.ok_or_else(|| eyre::eyre!("Branch name was not UTF-8: {self:?}"))?;
let config = self.repo.get_readonly_config()?;
let pull_remote_name = config.get(format!("branch.{branch_name}.remote"))?;
Ok(pull_remote_name)
}

/// Get the associated remote to push to for this branch. If there is no
/// associated remote, returns `None`. Note that this never reads the value
/// of `push.remoteDefault`.
Expand Down
4 changes: 1 addition & 3 deletions git-branchless-lib/src/git/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,14 @@ use std::{io, time};

use bstr::ByteVec;
use chrono::{DateTime, Utc};
use cursive::theme::BaseColor;
use cursive::utils::markup::StyledString;
use git2::DiffOptions;
use itertools::Itertools;
use thiserror::Error;
use tracing::{instrument, warn};

use crate::core::effects::{Effects, OperationType};
use crate::core::eventlog::EventTransactionId;
use crate::core::formatting::Glyphs;
use crate::core::formatting::{BaseColor, Glyphs, StyledString};
use crate::git::config::{Config, ConfigRead};
use crate::git::object::Blob;
use crate::git::oid::{make_non_zero_oid, MaybeZeroOid, NonZeroOid};
Expand Down
1 change: 1 addition & 0 deletions git-branchless-lib/src/git/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ impl std::fmt::Debug for GitRunInfo {
}

/// Options for invoking Git.
#[derive(Clone)]
pub struct GitRunOpts {
/// If set, a non-zero exit code will be treated as an error.
pub treat_git_failure_as_error: bool,
Expand Down
9 changes: 5 additions & 4 deletions git-branchless-lib/src/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,11 @@ stderr:
if subcommand_mtime > main_command_mtime {
result.suggestion(format!(
"\
The modified time for {main_command_exe:?} was before the modified time for
{subcommand_exe:?}, which may indicate that you made changes to the subcommand
without building the main executable. This may cause spurious test failures
because the main executable code is out of date.
The modified time for {main_command_exe:?}: {main_command_mtime:?}
was before the modified time for {subcommand_exe:?}: {subcommand_mtime:?}
which may indicate that you made changes to the subcommand without building the
main executable. This may cause spurious test failures because the main
executable code is out of date.

If so, you should either explicitly run: cargo -p git-branchless
to build the main executable before running this test; or, if it's okay to skip
Expand Down
1 change: 0 additions & 1 deletion git-branchless-navigation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ repository = "https://github.com/arxanas/git-branchless"
version = "0.10.0"

[dependencies]
cursive = { workspace = true }
eden_dag = { workspace = true }
eyre = { workspace = true }
git-branchless-opts = { workspace = true }
Expand Down
5 changes: 1 addition & 4 deletions git-branchless-navigation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ use std::ffi::OsString;
use std::fmt::Write;
use std::time::SystemTime;

use cursive::theme::BaseColor;
use cursive::utils::markup::StyledString;

use lib::core::check_out::{check_out_commit, CheckOutCommitOptions, CheckoutTarget};
use lib::core::repo_ext::RepoExt;
use lib::util::{ExitCode, EyreExitOr};
Expand All @@ -32,7 +29,7 @@ use lib::core::config::get_next_interactive;
use lib::core::dag::{sorted_commit_set, CommitSet, Dag};
use lib::core::effects::Effects;
use lib::core::eventlog::{EventLogDb, EventReplayer};
use lib::core::formatting::Pluralize;
use lib::core::formatting::{BaseColor, Pluralize, StyledString};
use lib::core::node_descriptors::{
BranchesDescriptor, CommitMessageDescriptor, CommitOidDescriptor,
DifferentialRevisionDescriptor, NodeDescriptor, Redactor, RelativeTimeDescriptor,
Expand Down
4 changes: 0 additions & 4 deletions git-branchless-record/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ repository = "https://github.com/arxanas/git-branchless"
version = "0.10.0"

[dependencies]
cursive = { version = "0.20.0", default-features = false, features = [
"crossterm-backend",
] }
cursive_buffered_backend = { workspace = true }
eden_dag = { workspace = true }
eyre = { workspace = true }
git-branchless-invoke = { workspace = true }
Expand Down
1 change: 0 additions & 1 deletion git-branchless-smartlog/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ repository = "https://github.com/arxanas/git-branchless"
version = "0.10.0"

[dependencies]
cursive_core = { workspace = true }
eden_dag = { workspace = true }
eyre = { workspace = true }
git-branchless-invoke = { workspace = true }
Expand Down
7 changes: 3 additions & 4 deletions git-branchless-smartlog/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,14 +377,13 @@ mod render {
use std::cmp::Ordering;
use std::collections::HashSet;

use cursive_core::theme::{BaseColor, Effect};
use cursive_core::utils::markup::StyledString;
use tracing::instrument;

use lib::core::dag::{CommitSet, Dag};
use lib::core::effects::Effects;
use lib::core::formatting::{set_effect, Pluralize};
use lib::core::formatting::{Glyphs, StyledStringBuilder};
use lib::core::formatting::{
set_effect, BaseColor, Effect, Glyphs, Pluralize, StyledString, StyledStringBuilder,
};
use lib::core::node_descriptors::{render_node_descriptors, NodeDescriptor};
use lib::git::{NonZeroOid, Repo};

Expand Down
1 change: 0 additions & 1 deletion git-branchless-submit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ version = "0.10.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
cursive_core = { workspace = true }
eden_dag = { workspace = true }
eyre = { workspace = true }
git-branchless-invoke = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion git-branchless-submit/src/branch_forge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ These remotes are available: {}",
commit_status.local_commit_name.map(|local_commit_name| {
(
commit_oid,
CreateStatus {
CreateStatus::Created {
final_commit_oid: commit_oid,
local_commit_name,
},
Expand Down
Loading
Loading