mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-09-20 00:27:17 +03:00
fix rustfmt formatting issues due to line-length (#3039)
The trick is to temporarily set `max_width` in `rustfmt.toml` to 120, then set it back to the default of 100 (or remove the file).
This commit is contained in:
parent
5ea4bb3c58
commit
aa3d3cb7da
@ -93,15 +93,12 @@ impl Proxy {
|
||||
|
||||
async fn proxy_author(&self, author: Author) -> Author {
|
||||
Author {
|
||||
gravatar_url: self
|
||||
.proxy(&author.gravatar_url)
|
||||
.await
|
||||
.unwrap_or_else(|error| {
|
||||
tracing::error!(gravatar_url = %author.gravatar_url, ?error, "failed to proxy gravatar url");
|
||||
author.gravatar_url
|
||||
}),
|
||||
..author
|
||||
}
|
||||
gravatar_url: self.proxy(&author.gravatar_url).await.unwrap_or_else(|error| {
|
||||
tracing::error!(gravatar_url = %author.gravatar_url, ?error, "failed to proxy gravatar url");
|
||||
author.gravatar_url
|
||||
}),
|
||||
..author
|
||||
}
|
||||
}
|
||||
|
||||
async fn proxy_remote_commit(&self, commit: RemoteCommit) -> RemoteCommit {
|
||||
|
@ -217,7 +217,8 @@ impl Repository {
|
||||
|
||||
// Push to the remote
|
||||
remote
|
||||
.push(&[&remote_refspec], Some(&mut push_options)).map_err(|error| match error {
|
||||
.push(&[&remote_refspec], Some(&mut push_options))
|
||||
.map_err(|error| match error {
|
||||
git::Error::Network(error) => {
|
||||
tracing::warn!(project_id = %self.project.id, error = %error, "failed to push gb repo");
|
||||
RemoteError::Network
|
||||
|
@ -61,7 +61,7 @@ impl Repository {
|
||||
// XXX(qix-): We will ultimately move away from an internal repository for a variety
|
||||
// XXX(qix-): of reasons, but for now, this is a simple, short-term solution that we
|
||||
// XXX(qix-): can clean up later on. We're aware this isn't ideal.
|
||||
if let Ok(config) = git_repository.config().as_mut(){
|
||||
if let Ok(config) = git_repository.config().as_mut() {
|
||||
let should_set = match config.get_bool("gitbutler.didSetPrune") {
|
||||
Ok(None | Some(false)) => true,
|
||||
Ok(Some(true)) => false,
|
||||
@ -76,7 +76,10 @@ impl Repository {
|
||||
};
|
||||
|
||||
if should_set {
|
||||
if let Err(error) = config.set_str("gc.pruneExpire", "never").and_then(|()| config.set_bool("gitbutler.didSetPrune", true)) {
|
||||
if let Err(error) = config
|
||||
.set_str("gc.pruneExpire", "never")
|
||||
.and_then(|()| config.set_bool("gitbutler.didSetPrune", true))
|
||||
{
|
||||
tracing::warn!(
|
||||
"failed to set gc.auto to false for repository at {}; cannot disable gc: {}",
|
||||
project.path.display(),
|
||||
|
@ -569,9 +569,10 @@ pub fn update_base_branch(
|
||||
})
|
||||
.context("failed to calculate final tree")?;
|
||||
|
||||
repo.checkout_tree(&final_tree).force().checkout().context(
|
||||
"failed to checkout index, this should not have happened, we should have already detected this",
|
||||
)?;
|
||||
repo.checkout_tree(&final_tree)
|
||||
.force()
|
||||
.checkout()
|
||||
.context("failed to checkout index, this should not have happened, we should have already detected this")?;
|
||||
|
||||
// write new target oid
|
||||
vb_state.set_default_target(target::Target {
|
||||
|
@ -64,7 +64,10 @@ async fn conflicting() {
|
||||
assert_eq!(branches.len(), 1);
|
||||
assert!(branches[0].base_current);
|
||||
assert!(branches[0].active);
|
||||
assert_eq!(branches[0].files[0].hunks[0].diff, "@@ -1 +1 @@\n-first\n\\ No newline at end of file\n+conflict\n\\ No newline at end of file\n");
|
||||
assert_eq!(
|
||||
branches[0].files[0].hunks[0].diff,
|
||||
"@@ -1 +1 @@\n-first\n\\ No newline at end of file\n+conflict\n\\ No newline at end of file\n"
|
||||
);
|
||||
|
||||
controller
|
||||
.unapply_virtual_branch(project_id, &branches[0].id)
|
||||
@ -142,7 +145,10 @@ async fn conflicting() {
|
||||
assert!(!branch.active);
|
||||
assert!(!branch.base_current);
|
||||
assert!(!branch.conflicted);
|
||||
assert_eq!(branch.files[0].hunks[0].diff, "@@ -1 +1 @@\n-first\n\\ No newline at end of file\n+conflict\n\\ No newline at end of file\n");
|
||||
assert_eq!(
|
||||
branch.files[0].hunks[0].diff,
|
||||
"@@ -1 +1 @@\n-first\n\\ No newline at end of file\n+conflict\n\\ No newline at end of file\n"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1635,7 +1635,10 @@ mod applied_branch {
|
||||
assert!(branches[0].base_current);
|
||||
assert_eq!(branches[0].files.len(), 1);
|
||||
assert_eq!(branches[0].files[0].hunks.len(), 1);
|
||||
assert_eq!(branches[0].files[0].hunks[0].diff, "@@ -4,7 +4,11 @@\n 4\n 5\n 6\n-7\n+<<<<<<< ours\n+77\n+=======\n+17\n+>>>>>>> theirs\n 8\n 19\n 10\n");
|
||||
assert_eq!(
|
||||
branches[0].files[0].hunks[0].diff,
|
||||
"@@ -4,7 +4,11 @@\n 4\n 5\n 6\n-7\n+<<<<<<< ours\n+77\n+=======\n+17\n+>>>>>>> theirs\n 8\n 19\n 10\n"
|
||||
);
|
||||
assert_eq!(branches[0].commits.len(), 0);
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,9 @@ use std::io::{BufRead, BufReader, BufWriter, Write};
|
||||
pub fn main() {
|
||||
let pipe_name = std::env::var("GITBUTLER_ASKPASS_PIPE").expect("do not run this binary yourself; it's only meant to be run by GitButler (missing GITBUTLER_ASKPASS_PIPE env var)");
|
||||
let pipe_secret = std::env::var("GITBUTLER_ASKPASS_SECRET").expect("do not run this binary yourself; it's only meant to be run by GitButler (missing GITBUTLER_ASKPASS_SECRET env var)");
|
||||
let prompt = std::env::args().nth(1).expect("do not run this binary yourself; it's only meant to be run by GitButler (missing prompt arg)");
|
||||
let prompt = std::env::args()
|
||||
.nth(1)
|
||||
.expect("do not run this binary yourself; it's only meant to be run by GitButler (missing prompt arg)");
|
||||
|
||||
#[cfg(unix)]
|
||||
let raw_stream = self::unix::establish(&pipe_name);
|
||||
|
@ -23,9 +23,7 @@ pub enum RepositoryError<
|
||||
AskpassServer(Easkpass),
|
||||
#[error("i/o error communicating with askpass utility: {0}")]
|
||||
AskpassIo(Esocket),
|
||||
#[error(
|
||||
"git command exited with non-zero exit code {status}: {args:?}\n\nSTDOUT:\n{stdout}\n\nSTDERR:\n{stderr}"
|
||||
)]
|
||||
#[error("git command exited with non-zero exit code {status}: {args:?}\n\nSTDOUT:\n{stdout}\n\nSTDERR:\n{stderr}")]
|
||||
Failed {
|
||||
status: usize,
|
||||
args: Vec<String>,
|
||||
|
@ -19,24 +19,37 @@ static SENTRY_LIMIT: OnceCell<RateLimiter<NotKeyed, InMemoryState, QuantaClock>>
|
||||
/// Should be called once on application startup, and the returned guard should be kept alive for
|
||||
/// the lifetime of the application.
|
||||
pub fn init(name: &str, version: String) -> ClientInitGuard {
|
||||
sentry::init(("https://9d407634d26b4d30b6a42d57a136d255@o4504644069687296.ingest.sentry.io/4504649768108032", sentry::ClientOptions {
|
||||
environment: Some(match name {
|
||||
"GitButler" => "production",
|
||||
"GitButler Nightly" => "nightly",
|
||||
"GitButler Dev" => "development",
|
||||
_ => "unknown",
|
||||
}.into()),
|
||||
release: Some(version.into()),
|
||||
before_send: Some({
|
||||
Arc::new(|event| SENTRY_LIMIT.get_or_init(|| RateLimiter::direct(SENTRY_QUOTA)).check().is_ok().then_some(event))}),
|
||||
attach_stacktrace: true,
|
||||
traces_sample_rate: match name {
|
||||
"GitButler Dev" | "GitButler Nightly" => 0.2_f32,
|
||||
_ => 0.05_f32,
|
||||
sentry::init((
|
||||
"https://9d407634d26b4d30b6a42d57a136d255@o4504644069687296.ingest.sentry.io/4504649768108032",
|
||||
sentry::ClientOptions {
|
||||
environment: Some(
|
||||
match name {
|
||||
"GitButler" => "production",
|
||||
"GitButler Nightly" => "nightly",
|
||||
"GitButler Dev" => "development",
|
||||
_ => "unknown",
|
||||
}
|
||||
.into(),
|
||||
),
|
||||
release: Some(version.into()),
|
||||
before_send: Some({
|
||||
Arc::new(|event| {
|
||||
SENTRY_LIMIT
|
||||
.get_or_init(|| RateLimiter::direct(SENTRY_QUOTA))
|
||||
.check()
|
||||
.is_ok()
|
||||
.then_some(event)
|
||||
})
|
||||
}),
|
||||
attach_stacktrace: true,
|
||||
traces_sample_rate: match name {
|
||||
"GitButler Dev" | "GitButler Nightly" => 0.2_f32,
|
||||
_ => 0.05_f32,
|
||||
},
|
||||
default_integrations: true,
|
||||
..Default::default()
|
||||
},
|
||||
default_integrations: true,
|
||||
..Default::default()
|
||||
}))
|
||||
))
|
||||
}
|
||||
|
||||
/// Sets the current user in the Sentry scope.
|
||||
|
@ -92,17 +92,16 @@ pub fn spawn(
|
||||
tracing::error!(?err, "ignored file watcher error");
|
||||
}
|
||||
Ok(events) => {
|
||||
let maybe_repo = git::Repository::open(&worktree_path).with_context(
|
||||
|| {
|
||||
format!(
|
||||
"failed to open project repository: {}",
|
||||
worktree_path.display()
|
||||
)
|
||||
},
|
||||
).map(Some).unwrap_or_else(|err| {
|
||||
tracing::error!(?err, "will consider changes to all files as repository couldn't be opened");
|
||||
None
|
||||
});
|
||||
let maybe_repo = git::Repository::open(&worktree_path)
|
||||
.with_context(|| format!("failed to open project repository: {}", worktree_path.display()))
|
||||
.map(Some)
|
||||
.unwrap_or_else(|err| {
|
||||
tracing::error!(
|
||||
?err,
|
||||
"will consider changes to all files as repository couldn't be opened"
|
||||
);
|
||||
None
|
||||
});
|
||||
|
||||
let num_events = events.len();
|
||||
let classified_file_paths = events
|
||||
@ -121,26 +120,24 @@ pub fn spawn(
|
||||
match kind {
|
||||
FileKind::ProjectIgnored => ignored += 1,
|
||||
FileKind::GitUninteresting => git_noop += 1,
|
||||
FileKind::Project | FileKind::Git => {
|
||||
match file_path.strip_prefix(&worktree_path) {
|
||||
Ok(relative_file_path) => {
|
||||
if relative_file_path.as_os_str().is_empty() {
|
||||
continue;
|
||||
}
|
||||
if let Ok(stripped) =
|
||||
relative_file_path.strip_prefix(".git")
|
||||
{
|
||||
stripped_git_paths.insert(stripped.to_owned());
|
||||
} else {
|
||||
worktree_relative_paths
|
||||
.insert(relative_file_path.to_owned());
|
||||
};
|
||||
}
|
||||
Err(err) => {
|
||||
tracing::error!(%project_id, ?err, "failed to strip prefix");
|
||||
FileKind::Project | FileKind::Git => match file_path
|
||||
.strip_prefix(&worktree_path)
|
||||
{
|
||||
Ok(relative_file_path) => {
|
||||
if relative_file_path.as_os_str().is_empty() {
|
||||
continue;
|
||||
}
|
||||
if let Ok(stripped) = relative_file_path.strip_prefix(".git") {
|
||||
stripped_git_paths.insert(stripped.to_owned());
|
||||
} else {
|
||||
worktree_relative_paths
|
||||
.insert(relative_file_path.to_owned());
|
||||
};
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
tracing::error!(%project_id, ?err, "failed to strip prefix");
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -240,13 +240,11 @@ impl Handler {
|
||||
.build();
|
||||
|
||||
let fetch_result = backoff::retry(policy, || {
|
||||
gb_repo.fetch(user.as_ref()).map_err(|err| {
|
||||
match err {
|
||||
gb_repository::RemoteError::Network => backoff::Error::permanent(err),
|
||||
err @ gb_repository::RemoteError::Other(_) => {
|
||||
tracing::warn!(%project_id, ?err, will_retry = true, "failed to fetch project data");
|
||||
backoff::Error::transient(err)
|
||||
}
|
||||
gb_repo.fetch(user.as_ref()).map_err(|err| match err {
|
||||
gb_repository::RemoteError::Network => backoff::Error::permanent(err),
|
||||
err @ gb_repository::RemoteError::Other(_) => {
|
||||
tracing::warn!(%project_id, ?err, will_retry = true, "failed to fetch project data");
|
||||
backoff::Error::transient(err)
|
||||
}
|
||||
})
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user