Skip to content

Commit c454cb8

Browse files
committed
Lint
1 parent 2110801 commit c454cb8

File tree

10 files changed

+198
-100
lines changed

10 files changed

+198
-100
lines changed

apps/buzz/dev.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env node
22

3-
const { spawn } = require('child_process');
4-
const path = require('path');
5-
const net = require('net');
3+
import { spawn } from 'child_process';
4+
import net from 'net';
5+
import path from 'path';
66

77
// Colors for console output
88
const colors = {
@@ -25,6 +25,7 @@ let electronProcess = null;
2525
let butProcess = null;
2626

2727
function log(message, color = colors.reset) {
28+
// eslint-disable-next-line no-console
2829
console.log(`${color}${message}${colors.reset}`);
2930
}
3031

@@ -42,8 +43,8 @@ function spawnProcess(command, args, cwd = process.cwd(), options = {}) {
4243
});
4344
}
4445

45-
function runCommand(command, args, cwd = process.cwd()) {
46-
return new Promise((resolve, reject) => {
46+
async function runCommand(command, args, cwd = process.cwd()) {
47+
return await new Promise((resolve, reject) => {
4748
log(`Running: ${command} ${args.join(' ')}`, colors.cyan);
4849

4950
const child = spawnProcess(command, args, cwd);
@@ -62,8 +63,8 @@ function runCommand(command, args, cwd = process.cwd()) {
6263
});
6364
}
6465

65-
function checkPort(port, host = 'localhost') {
66-
return new Promise((resolve) => {
66+
async function checkPort(port, host = 'localhost') {
67+
return await new Promise((resolve) => {
6768
const socket = new net.Socket();
6869

6970
socket.setTimeout(500);
@@ -129,9 +130,9 @@ async function main() {
129130
log('🚀 Starting GitButler Buzz Development Server', colors.bright + colors.green);
130131

131132
// Get paths
132-
const rootDir = path.resolve(__dirname, '../..');
133+
const rootDir = path.resolve(import.meta.dirname, '../..');
133134
const desktopDir = path.resolve(rootDir, 'apps/desktop');
134-
const buzzDir = __dirname;
135+
const buzzDir = import.meta.dirname;
135136

136137
log('\n🔧 Building TypeScript for Buzz...', colors.yellow);
137138

apps/buzz/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
"scripts": {
77
"dev": "node dev.js",
88
"dev:simple": "pnpm build-ts && electron .",
9-
"build-ts": "tsc",
10-
"test": "echo \"Error: no test specified\" && exit 1"
9+
"build-ts": "tsc"
1110
},
1211
"keywords": [],
1312
"author": "",

crates/but-server/src/cli.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::RequestContext;
2-
use anyhow::{anyhow, bail, Context};
2+
use anyhow::{Context, anyhow, bail};
33
use std::path::Path;
44

55
pub fn install_cli(
@@ -14,7 +14,8 @@ fn do_install_cli() -> anyhow::Result<()> {
1414
let cli_path = get_cli_path()?;
1515
if cfg!(windows) {
1616
bail!(
17-
"CLI installation is not supported on Windows. Please install manually by placing '{}' in PATH.", cli_path.display()
17+
"CLI installation is not supported on Windows. Please install manually by placing '{}' in PATH.",
18+
cli_path.display()
1819
);
1920
}
2021

@@ -94,10 +95,12 @@ pub fn cli_path(
9495
cli_path.display()
9596
));
9697
}
97-
Ok(serde_json::to_value(cli_path.to_string_lossy().to_string())?)
98+
Ok(serde_json::to_value(
99+
cli_path.to_string_lossy().to_string(),
100+
)?)
98101
}
99102

100103
fn get_cli_path() -> anyhow::Result<std::path::PathBuf> {
101104
let cli_path = std::env::current_exe()?;
102105
Ok(cli_path.with_file_name(if cfg!(windows) { "but.exe" } else { "but" }))
103-
}
106+
}

crates/but-server/src/commands.rs

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use gitbutler_project::ProjectId;
44
use gitbutler_repo::RepositoryExt;
55
use gitbutler_repo_actions::RepoActionsExt;
66
use serde::Deserialize;
7-
use serde_json::{json, Value};
7+
use serde_json::{Value, json};
88

99
use crate::RequestContext;
1010

@@ -63,7 +63,7 @@ struct GitGetGlobalConfigParams {
6363

6464
pub fn git_remote_branches(ctx: &RequestContext, params: Value) -> anyhow::Result<Value> {
6565
let params: GitRemoteBranchesParams = serde_json::from_value(params)?;
66-
66+
6767
let project = ctx.project_controller.get(params.project_id)?;
6868
let command_ctx = CommandContext::open(&project, ctx.app_settings.get()?.clone())?;
6969
let branches = command_ctx.repo().remote_branches()?;
@@ -72,7 +72,7 @@ pub fn git_remote_branches(ctx: &RequestContext, params: Value) -> anyhow::Resul
7272

7373
pub fn git_test_push(ctx: &RequestContext, params: Value) -> anyhow::Result<Value> {
7474
let params: GitTestPushParams = serde_json::from_value(params)?;
75-
75+
7676
let project = ctx.project_controller.get(params.project_id)?;
7777
let command_ctx = CommandContext::open(&project, ctx.app_settings.get()?.clone())?;
7878
command_ctx.git_test_push(&params.remote_name, &params.branch_name, Some(None))?;
@@ -81,16 +81,19 @@ pub fn git_test_push(ctx: &RequestContext, params: Value) -> anyhow::Result<Valu
8181

8282
pub fn git_test_fetch(ctx: &RequestContext, params: Value) -> anyhow::Result<Value> {
8383
let params: GitTestFetchParams = serde_json::from_value(params)?;
84-
84+
8585
let project = ctx.project_controller.get(params.project_id)?;
8686
let command_ctx = CommandContext::open(&project, ctx.app_settings.get()?.clone())?;
87-
command_ctx.fetch(&params.remote_name, Some(params.action.unwrap_or_else(|| "test".to_string())))?;
87+
command_ctx.fetch(
88+
&params.remote_name,
89+
Some(params.action.unwrap_or_else(|| "test".to_string())),
90+
)?;
8891
Ok(json!({}))
8992
}
9093

9194
pub fn git_index_size(ctx: &RequestContext, params: Value) -> anyhow::Result<Value> {
9295
let params: GitIndexSizeParams = serde_json::from_value(params)?;
93-
96+
9497
let project = ctx.project_controller.get(params.project_id)?;
9598
let command_ctx = CommandContext::open(&project, ctx.app_settings.get()?.clone())?;
9699
let size = command_ctx
@@ -103,15 +106,22 @@ pub fn git_index_size(ctx: &RequestContext, params: Value) -> anyhow::Result<Val
103106

104107
pub fn git_head(ctx: &RequestContext, params: Value) -> anyhow::Result<Value> {
105108
let params: GitHeadParams = serde_json::from_value(params)?;
106-
109+
107110
let project = ctx.project_controller.get(params.project_id)?;
108111
let command_ctx = CommandContext::open(&project, ctx.app_settings.get()?.clone())?;
109-
let head = command_ctx.repo().head().context("failed to get repository head")?;
112+
let head = command_ctx
113+
.repo()
114+
.head()
115+
.context("failed to get repository head")?;
110116
Ok(json!(head.name().unwrap().to_string()))
111117
}
112118

113119
pub fn delete_all_data(ctx: &RequestContext, _params: Value) -> anyhow::Result<Value> {
114-
for project in ctx.project_controller.list().context("failed to list projects")? {
120+
for project in ctx
121+
.project_controller
122+
.list()
123+
.context("failed to list projects")?
124+
{
115125
ctx.project_controller
116126
.delete(project.id)
117127
.map_err(|err| err.context("failed to delete project"))?;
@@ -121,23 +131,23 @@ pub fn delete_all_data(ctx: &RequestContext, _params: Value) -> anyhow::Result<V
121131

122132
pub fn git_set_global_config(_ctx: &RequestContext, params: Value) -> anyhow::Result<Value> {
123133
let params: GitSetGlobalConfigParams = serde_json::from_value(params)?;
124-
134+
125135
let mut config = git2::Config::open_default()?;
126136
config.set_str(&params.key, &params.value)?;
127137
Ok(json!(params.value))
128138
}
129139

130140
pub fn git_remove_global_config(_ctx: &RequestContext, params: Value) -> anyhow::Result<Value> {
131141
let params: GitRemoveGlobalConfigParams = serde_json::from_value(params)?;
132-
142+
133143
let mut config = git2::Config::open_default()?;
134144
config.remove(&params.key)?;
135145
Ok(json!({}))
136146
}
137147

138148
pub fn git_get_global_config(_ctx: &RequestContext, params: Value) -> anyhow::Result<Value> {
139149
let params: GitGetGlobalConfigParams = serde_json::from_value(params)?;
140-
150+
141151
let config = git2::Config::open_default()?;
142152
let value = config.get_string(&params.key);
143153
match value {
@@ -150,4 +160,4 @@ pub fn git_get_global_config(_ctx: &RequestContext, params: Value) -> anyhow::Re
150160
}
151161
}
152162
}
153-
}
163+
}

crates/but-server/src/modes.rs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use gitbutler_command_context::CommandContext;
44
use gitbutler_project::ProjectId;
55
use gitbutler_stack::VirtualBranchesHandle;
66
use serde::Deserialize;
7-
use serde_json::{json, Value};
7+
use serde_json::{Value, json};
88

99
use crate::RequestContext;
1010

@@ -30,7 +30,7 @@ struct ProjectOnlyParams {
3030

3131
pub fn operating_mode(ctx: &RequestContext, params: Value) -> anyhow::Result<Value> {
3232
let params: OperatingModeParams = serde_json::from_value(params)?;
33-
33+
3434
let project = ctx.project_controller.get(params.project_id)?;
3535
let command_ctx = CommandContext::open(&project, ctx.app_settings.get()?.clone())?;
3636
let mode = gitbutler_operating_modes::operating_mode(&command_ctx);
@@ -39,7 +39,7 @@ pub fn operating_mode(ctx: &RequestContext, params: Value) -> anyhow::Result<Val
3939

4040
pub fn enter_edit_mode(ctx: &RequestContext, params: Value) -> anyhow::Result<Value> {
4141
let params: EnterEditModeParams = serde_json::from_value(params)?;
42-
42+
4343
let project = ctx.project_controller.get(params.project_id)?;
4444
let command_ctx = CommandContext::open(&project, ctx.app_settings.get()?.clone())?;
4545
let handle = VirtualBranchesHandle::new(project.gb_dir());
@@ -52,13 +52,16 @@ pub fn enter_edit_mode(ctx: &RequestContext, params: Value) -> anyhow::Result<Va
5252
commit,
5353
stack.refname()?.to_string().into(),
5454
)?;
55-
55+
5656
Ok(serde_json::to_value(metadata)?)
5757
}
5858

59-
pub fn abort_edit_and_return_to_workspace(ctx: &RequestContext, params: Value) -> anyhow::Result<Value> {
59+
pub fn abort_edit_and_return_to_workspace(
60+
ctx: &RequestContext,
61+
params: Value,
62+
) -> anyhow::Result<Value> {
6063
let params: ProjectOnlyParams = serde_json::from_value(params)?;
61-
64+
6265
let project = ctx.project_controller.get(params.project_id)?;
6366
let command_ctx = CommandContext::open(&project, ctx.app_settings.get()?.clone())?;
6467

@@ -67,9 +70,12 @@ pub fn abort_edit_and_return_to_workspace(ctx: &RequestContext, params: Value) -
6770
Ok(json!({}))
6871
}
6972

70-
pub fn save_edit_and_return_to_workspace(ctx: &RequestContext, params: Value) -> anyhow::Result<Value> {
73+
pub fn save_edit_and_return_to_workspace(
74+
ctx: &RequestContext,
75+
params: Value,
76+
) -> anyhow::Result<Value> {
7177
let params: ProjectOnlyParams = serde_json::from_value(params)?;
72-
78+
7379
let project = ctx.project_controller.get(params.project_id)?;
7480
let command_ctx = CommandContext::open(&project, ctx.app_settings.get()?.clone())?;
7581

@@ -80,10 +86,10 @@ pub fn save_edit_and_return_to_workspace(ctx: &RequestContext, params: Value) ->
8086

8187
pub fn edit_initial_index_state(ctx: &RequestContext, params: Value) -> anyhow::Result<Value> {
8288
let params: ProjectOnlyParams = serde_json::from_value(params)?;
83-
89+
8490
let project = ctx.project_controller.get(params.project_id)?;
8591
let command_ctx = CommandContext::open(&project, ctx.app_settings.get()?.clone())?;
8692

8793
let state = gitbutler_edit_mode::commands::starting_index_state(&command_ctx)?;
8894
Ok(serde_json::to_value(state)?)
89-
}
95+
}

crates/but-server/src/stack.rs

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use gitbutler_project::ProjectId;
44
use gitbutler_stack::StackId;
55
use gitbutler_user::User;
66
use serde::Deserialize;
7-
use serde_json::{json, Value};
7+
use serde_json::{Value, json};
88

99
use crate::RequestContext;
1010

@@ -71,7 +71,7 @@ struct PushStackToReviewParams {
7171

7272
pub fn create_branch(ctx: &RequestContext, params: Value) -> anyhow::Result<Value> {
7373
let params: CreateBranchParams = serde_json::from_value(params)?;
74-
74+
7575
let project = ctx.project_controller.get(params.project_id)?;
7676
let command_ctx = CommandContext::open(&project, ctx.app_settings.get()?.clone())?;
7777
gitbutler_branch_actions::stack::create_branch(&command_ctx, params.stack_id, params.request)?;
@@ -80,25 +80,34 @@ pub fn create_branch(ctx: &RequestContext, params: Value) -> anyhow::Result<Valu
8080

8181
pub fn remove_branch(ctx: &RequestContext, params: Value) -> anyhow::Result<Value> {
8282
let params: RemoveBranchParams = serde_json::from_value(params)?;
83-
83+
8484
let project = ctx.project_controller.get(params.project_id)?;
8585
let command_ctx = CommandContext::open(&project, ctx.app_settings.get()?.clone())?;
86-
gitbutler_branch_actions::stack::remove_branch(&command_ctx, params.stack_id, params.branch_name)?;
86+
gitbutler_branch_actions::stack::remove_branch(
87+
&command_ctx,
88+
params.stack_id,
89+
params.branch_name,
90+
)?;
8791
Ok(json!({}))
8892
}
8993

9094
pub fn update_branch_name(ctx: &RequestContext, params: Value) -> anyhow::Result<Value> {
9195
let params: UpdateBranchNameParams = serde_json::from_value(params)?;
92-
96+
9397
let project = ctx.project_controller.get(params.project_id)?;
9498
let command_ctx = CommandContext::open(&project, ctx.app_settings.get()?.clone())?;
95-
gitbutler_branch_actions::stack::update_branch_name(&command_ctx, params.stack_id, params.branch_name, params.new_name)?;
99+
gitbutler_branch_actions::stack::update_branch_name(
100+
&command_ctx,
101+
params.stack_id,
102+
params.branch_name,
103+
params.new_name,
104+
)?;
96105
Ok(json!({}))
97106
}
98107

99108
pub fn update_branch_description(ctx: &RequestContext, params: Value) -> anyhow::Result<Value> {
100109
let params: UpdateBranchDescriptionParams = serde_json::from_value(params)?;
101-
110+
102111
let project = ctx.project_controller.get(params.project_id)?;
103112
let command_ctx = CommandContext::open(&project, ctx.app_settings.get()?.clone())?;
104113
gitbutler_branch_actions::stack::update_branch_description(
@@ -112,7 +121,7 @@ pub fn update_branch_description(ctx: &RequestContext, params: Value) -> anyhow:
112121

113122
pub fn update_branch_pr_number(ctx: &RequestContext, params: Value) -> anyhow::Result<Value> {
114123
let params: UpdateBranchPrNumberParams = serde_json::from_value(params)?;
115-
124+
116125
let project = ctx.project_controller.get(params.project_id)?;
117126
let command_ctx = CommandContext::open(&project, ctx.app_settings.get()?.clone())?;
118127
gitbutler_branch_actions::stack::update_branch_pr_number(
@@ -126,19 +135,29 @@ pub fn update_branch_pr_number(ctx: &RequestContext, params: Value) -> anyhow::R
126135

127136
pub fn push_stack(ctx: &RequestContext, params: Value) -> anyhow::Result<Value> {
128137
let params: PushStackParams = serde_json::from_value(params)?;
129-
138+
130139
let project = ctx.project_controller.get(params.project_id)?;
131140
let command_ctx = CommandContext::open(&project, ctx.app_settings.get()?.clone())?;
132-
gitbutler_branch_actions::stack::push_stack(&command_ctx, params.stack_id, params.with_force, params.branch)?;
141+
gitbutler_branch_actions::stack::push_stack(
142+
&command_ctx,
143+
params.stack_id,
144+
params.with_force,
145+
params.branch,
146+
)?;
133147
Ok(json!({}))
134148
}
135149

136150
pub fn push_stack_to_review(ctx: &RequestContext, params: Value) -> anyhow::Result<Value> {
137151
let params: PushStackToReviewParams = serde_json::from_value(params)?;
138-
152+
139153
let project = ctx.project_controller.get(params.project_id)?;
140154
let command_ctx = CommandContext::open(&project, ctx.app_settings.get()?.clone())?;
141-
let review_id = gitbutler_sync::stack_upload::push_stack_to_review(&command_ctx, &params.user, params.stack_id, params.top_branch)?;
155+
let review_id = gitbutler_sync::stack_upload::push_stack_to_review(
156+
&command_ctx,
157+
&params.user,
158+
params.stack_id,
159+
params.top_branch,
160+
)?;
142161

143162
Ok(json!(review_id))
144-
}
163+
}

0 commit comments

Comments
 (0)