diff --git a/gitbutler-app/src/app.rs b/gitbutler-app/src/app.rs index d46b6d2fd..77abbc519 100644 --- a/gitbutler-app/src/app.rs +++ b/gitbutler-app/src/app.rs @@ -145,6 +145,15 @@ impl App { .map_err(|e| Error::Other(anyhow::anyhow!(e.to_string()))) } + pub fn git_index_size(&self, project_id: &ProjectId) -> Result { + let project = self.projects.get(project_id)?; + let project_repository = project_repository::Repository::open(&project)?; + let size = project_repository + .git_index_size() + .context("failed to get index size")?; + Ok(size) + } + pub fn git_head(&self, project_id: &ProjectId) -> Result { let project = self.projects.get(project_id)?; let project_repository = project_repository::Repository::open(&project)?; diff --git a/gitbutler-app/src/commands.rs b/gitbutler-app/src/commands.rs index 04477bdad..56a92615b 100644 --- a/gitbutler-app/src/commands.rs +++ b/gitbutler-app/src/commands.rs @@ -103,6 +103,17 @@ pub async fn git_test_fetch( }) } +#[tauri::command(async)] +#[instrument(skip(handle))] +pub async fn git_index_size(handle: tauri::AppHandle, project_id: &str) -> Result { + let app = handle.state::(); + let project_id = project_id.parse().map_err(|_| Error::UserError { + code: Code::Validation, + message: "Malformed project id".to_string(), + })?; + Ok(app.git_index_size(&project_id).expect("git index size")) +} + #[tauri::command(async)] #[instrument(skip(handle))] pub async fn git_head(handle: tauri::AppHandle, project_id: &str) -> Result { diff --git a/gitbutler-app/src/git/repository.rs b/gitbutler-app/src/git/repository.rs index f567c7158..7893c12bf 100644 --- a/gitbutler-app/src/git/repository.rs +++ b/gitbutler-app/src/git/repository.rs @@ -224,6 +224,10 @@ impl Repository { self.0.index().map(Into::into).map_err(Into::into) } + pub fn index_size(&self) -> Result { + Ok(self.0.index()?.len()) + } + pub fn blob_path>(&self, path: P) -> Result { self.0 .blob_path(path.as_ref()) diff --git a/gitbutler-app/src/main.rs b/gitbutler-app/src/main.rs index 80061616f..2f65abd22 100644 --- a/gitbutler-app/src/main.rs +++ b/gitbutler-app/src/main.rs @@ -240,6 +240,7 @@ fn main() { commands::project_flush_and_push, commands::git_test_push, commands::git_test_fetch, + commands::git_index_size, zip::commands::get_logs_archive_path, zip::commands::get_project_archive_path, zip::commands::get_project_data_archive_path, diff --git a/gitbutler-app/src/project_repository/repository.rs b/gitbutler-app/src/project_repository/repository.rs index 2d63c3aa6..4b4e7b15f 100644 --- a/gitbutler-app/src/project_repository/repository.rs +++ b/gitbutler-app/src/project_repository/repository.rs @@ -125,6 +125,11 @@ impl Repository { self.project = project.clone(); } + pub fn git_index_size(&self) -> Result { + let head = self.git_repository.index_size()?; + Ok(head) + } + pub fn get_head(&self) -> Result { let head = self.git_repository.head()?; Ok(head) diff --git a/gitbutler-ui/src/lib/backend/cloud.ts b/gitbutler-ui/src/lib/backend/cloud.ts index f4d9df3a2..ff8b0b00e 100644 --- a/gitbutler-ui/src/lib/backend/cloud.ts +++ b/gitbutler-ui/src/lib/backend/cloud.ts @@ -155,6 +155,7 @@ export function getCloudApiClient( const formData = new FormData(); formData.append('message', params.message); if (params.email) formData.append('email', params.email); + if (params.context) formData.append('context', params.context); if (params.logs) formData.append('logs', params.logs); if (params.repo) formData.append('repo', params.repo); if (params.data) formData.append('data', params.data); diff --git a/gitbutler-ui/src/lib/components/ShareIssueModal.svelte b/gitbutler-ui/src/lib/components/ShareIssueModal.svelte index 6f3906f69..5698c230a 100644 --- a/gitbutler-ui/src/lib/components/ShareIssueModal.svelte +++ b/gitbutler-ui/src/lib/components/ShareIssueModal.svelte @@ -1,10 +1,12 @@