project: Show detached head commit SHA in branch pickers (#29007)
When Git is in a detached HEAD state, the branch is `None`, and we can't get any meaningful information from it. This PR adds a `head_commit` field to the snapshot, which is always populated with the HEAD details, even when the branch is `None`. This also pave path to fix: https://github.com/zed-industries/zed/issues/28736 git panel branch picker (before, after): <img width="197" alt="image" src="https://github.com/user-attachments/assets/0b6abbba-2988-4890-a708-bcd8aad84f26" /> <img width="198" alt="image" src="https://github.com/user-attachments/assets/4b08b1a8-5e79-4aa3-a44e-932249602c18" /> title bar branch picker (before, after): <img width="183" alt="image" src="https://github.com/user-attachments/assets/d94357f8-a4da-4d60-8ddd-fdd978b99fdf" /> <img width="228" alt="image" src="https://github.com/user-attachments/assets/d20824a1-9279-44d6-afd1-bf9319fc50e4" /> Release Notes: - Added head commit SHA information to the Git branch picker in the title bar and Git panel.
This commit is contained in:
parent
c2cd4fd7a1
commit
ba7f886c62
8 changed files with 109 additions and 7 deletions
|
@ -117,6 +117,7 @@ CREATE TABLE "project_repositories" (
|
|||
"is_deleted" BOOL NOT NULL,
|
||||
"current_merge_conflicts" VARCHAR,
|
||||
"branch_summary" VARCHAR,
|
||||
"head_commit_details" VARCHAR,
|
||||
PRIMARY KEY (project_id, id)
|
||||
);
|
||||
|
||||
|
|
|
@ -348,9 +348,10 @@ impl Database {
|
|||
.unwrap(),
|
||||
)),
|
||||
|
||||
// Old clients do not use abs path or entry ids.
|
||||
// Old clients do not use abs path, entry ids or head_commit_details.
|
||||
abs_path: ActiveValue::set(String::new()),
|
||||
entry_ids: ActiveValue::set("[]".into()),
|
||||
head_commit_details: ActiveValue::set(None),
|
||||
}
|
||||
}),
|
||||
)
|
||||
|
@ -490,6 +491,12 @@ impl Database {
|
|||
.as_ref()
|
||||
.map(|summary| serde_json::to_string(summary).unwrap()),
|
||||
),
|
||||
head_commit_details: ActiveValue::Set(
|
||||
update
|
||||
.head_commit_details
|
||||
.as_ref()
|
||||
.map(|details| serde_json::to_string(details).unwrap()),
|
||||
),
|
||||
current_merge_conflicts: ActiveValue::Set(Some(
|
||||
serde_json::to_string(&update.current_merge_conflicts).unwrap(),
|
||||
)),
|
||||
|
@ -505,6 +512,7 @@ impl Database {
|
|||
project_repository::Column::EntryIds,
|
||||
project_repository::Column::AbsPath,
|
||||
project_repository::Column::CurrentMergeConflicts,
|
||||
project_repository::Column::HeadCommitDetails,
|
||||
])
|
||||
.to_owned(),
|
||||
)
|
||||
|
@ -928,6 +936,13 @@ impl Database {
|
|||
.transpose()?
|
||||
.unwrap_or_default();
|
||||
|
||||
let head_commit_details = db_repository_entry
|
||||
.head_commit_details
|
||||
.as_ref()
|
||||
.map(|head_commit_details| serde_json::from_str(&head_commit_details))
|
||||
.transpose()?
|
||||
.unwrap_or_default();
|
||||
|
||||
let entry_ids = serde_json::from_str(&db_repository_entry.entry_ids)
|
||||
.context("failed to deserialize repository's entry ids")?;
|
||||
|
||||
|
@ -954,6 +969,7 @@ impl Database {
|
|||
removed_statuses: Vec::new(),
|
||||
current_merge_conflicts,
|
||||
branch_summary,
|
||||
head_commit_details,
|
||||
scan_id: db_repository_entry.scan_id as u64,
|
||||
is_last_update: true,
|
||||
});
|
||||
|
|
|
@ -755,6 +755,13 @@ impl Database {
|
|||
.transpose()?
|
||||
.unwrap_or_default();
|
||||
|
||||
let head_commit_details = db_repository
|
||||
.head_commit_details
|
||||
.as_ref()
|
||||
.map(|head_commit_details| serde_json::from_str(&head_commit_details))
|
||||
.transpose()?
|
||||
.unwrap_or_default();
|
||||
|
||||
let entry_ids = serde_json::from_str(&db_repository.entry_ids)
|
||||
.context("failed to deserialize repository's entry ids")?;
|
||||
|
||||
|
@ -778,6 +785,7 @@ impl Database {
|
|||
removed_statuses,
|
||||
current_merge_conflicts,
|
||||
branch_summary,
|
||||
head_commit_details,
|
||||
project_id: project_id.to_proto(),
|
||||
id: db_repository.id as u64,
|
||||
abs_path: db_repository.abs_path,
|
||||
|
|
|
@ -18,6 +18,8 @@ pub struct Model {
|
|||
pub current_merge_conflicts: Option<String>,
|
||||
// A JSON object representing the current Branch values
|
||||
pub branch_summary: Option<String>,
|
||||
// A JSON object representing the current Head commit values
|
||||
pub head_commit_details: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue