zed/crates/fs/Cargo.toml

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

59 lines
1.2 KiB
TOML
Raw Normal View History

[package]
name = "fs"
version = "0.1.0"
edition = "2021"
publish = false
license = "GPL-3.0-or-later"
[lints]
workspace = true
[lib]
path = "src/fs.rs"
[dependencies]
anyhow.workspace = true
async-tar.workspace = true
async-trait.workspace = true
collections.workspace = true
futures.workspace = true
Add `git blame` (#8889) This adds a new action to the editor: `editor: toggle git blame`. When used it turns on a sidebar containing `git blame` information for the currently open buffer. The git blame information is updated when the buffer changes. It handles additions, deletions, modifications, changes to the underlying git data (new commits, changed commits, ...), file saves. It also handles folding and wrapping lines correctly. When the user hovers over a commit, a tooltip displays information for the commit that introduced the line. If the repository has a remote with the name `origin` configured, then clicking on a blame entry opens the permalink to the commit on the code host. Users can right-click on a blame entry to get a context menu which allows them to copy the SHA of the commit. The feature also works on shared projects, e.g. when collaborating a peer can request `git blame` data. As of this PR, Zed now comes bundled with a `git` binary so that users don't have to have `git` installed locally to use this feature. ### Screenshots ![screenshot-2024-03-28-13 57 43@2x](https://github.com/zed-industries/zed/assets/1185253/ee8ec55d-3b5e-4d63-a85a-852da914f5ba) ![screenshot-2024-03-28-14 01 23@2x](https://github.com/zed-industries/zed/assets/1185253/2ba8efd7-e887-4076-a87a-587a732b9e9a) ![screenshot-2024-03-28-14 01 32@2x](https://github.com/zed-industries/zed/assets/1185253/496f4a06-b189-4881-b427-2289ae6e6075) ### TODOs - [x] Bundling `git` binary ### Release Notes Release Notes: - Added `editor: toggle git blame` command that toggles a sidebar with git blame information for the current buffer. --------- Co-authored-by: Antonio <antonio@zed.dev> Co-authored-by: Piotr <piotr@zed.dev> Co-authored-by: Bennet <bennetbo@gmx.de> Co-authored-by: Mikayla <mikayla@zed.dev>
2024-03-28 17:32:11 +00:00
git.workspace = true
git2.workspace = true
gpui.workspace = true
libc.workspace = true
log.workspace = true
parking_lot.workspace = true
paths.workspace = true
rope.workspace = true
proto.workspace = true
serde.workspace = true
serde_json.workspace = true
smol.workspace = true
tempfile.workspace = true
text.workspace = true
2023-06-27 11:28:50 +00:00
time.workspace = true
util.workspace = true
[target.'cfg(target_os = "macos")'.dependencies]
fsevent.workspace = true
objc = "0.2"
cocoa = "0.26"
[target.'cfg(not(target_os = "macos"))'.dependencies]
notify = "6.1.1"
[target.'cfg(target_os = "windows")'.dependencies]
windows.workspace = true
[target.'cfg(any(target_os = "linux", target_os = "freebsd"))'.dependencies]
ashpd.workspace = true
linux: Fix saving file with root ownership (#22045) Closes #13585 Currently, saving files with `root` ownership or `root` as the group throws a `Permission denied (os error 13). Please try again.` error. This PR fixes the issue on Linux by prompting the user for a password and saving the file with elevated privileges. It uses `pkexec` (Polkit), which is by default available on GNOME, KDE, and most Linux systems. I haven't implemented this for macOS as I don't have a device to test it on. This implementation is similar to how Vscode handles it. Except, they don't show custom message. **Working**: When file saving fails due to a `PermissionDenied` error, we create a temporary file in the same directory as the target file and writes the data to this temporary file. After, the contents of this file are copied to the original file using the `tee` command instead of `cp` or `mv`. This ensures that the ownership and permissions of the original file are preserved. This command is executed using `pkexec` which will prompt user for their password. **Custom Message**: The message displayed to the user in the prompt is automatically retrieved from the `org.zed.app.policy` file, which is located at `/usr/share/polkit-1/actions/`. This file should be installed during the setup process. While the policy file is optional, omitting it will cause the user to see the underlying command being executed rather than a user-friendly message. Currently, VSCode does not display the user-friendly message. The policy file must specify a unique binary, ensuring that only that binary can use the policy file. It cannot be as generic as a `/bin/bash`, as any software using bash to prompt will end up showing Zed’s custom message. To address this, we will create a custom bash script, as simple as the following, placed in `/usr/bin/zed/elevate.sh`. The script should have root ownership and should not reside in the home directory, since the policy file cannot resolve `$HOME`. ```sh #!/bin/bash eval "$@" ``` *IMPORTANT NOTE* Since copying the policy file and our script requires sudo privileges, the installation script will now prompt for the password at very end. Only on Linux, if `pexec` is installed. Screenshots: KDE with policy file: ![Screenshot from 2024-12-15 22-13-06](https://github.com/user-attachments/assets/b8bb7565-85df-4c95-bb10-82e50acf9b56) Gnome with policy file: ![Screenshot from 2024-12-15 22-21-48](https://github.com/user-attachments/assets/83d15056-a2bd-41d9-a01d-9b8954260381) Gnome without policy file: ![image](https://github.com/user-attachments/assets/66c39d02-eed4-4f09-886f-621b6d37ff43) VSCode: ![image](https://github.com/user-attachments/assets/949dc470-c3df-4e2f-8cc6-31babaee1d18) User declines the permission request: ![image](https://github.com/user-attachments/assets/c5cbf056-f6f9-43a8-8d88-f2b0597e14d6) Release Notes: - Fixed file saving with root ownership on Linux.
2024-12-19 22:16:01 +00:00
which.workspace = true
shlex.workspace = true
[dev-dependencies]
gpui = { workspace = true, features = ["test-support"] }
2022-10-11 22:25:54 +00:00
[features]
test-support = ["gpui/test-support", "git/test-support"]
linux: Fix saving file with root ownership (#22045) Closes #13585 Currently, saving files with `root` ownership or `root` as the group throws a `Permission denied (os error 13). Please try again.` error. This PR fixes the issue on Linux by prompting the user for a password and saving the file with elevated privileges. It uses `pkexec` (Polkit), which is by default available on GNOME, KDE, and most Linux systems. I haven't implemented this for macOS as I don't have a device to test it on. This implementation is similar to how Vscode handles it. Except, they don't show custom message. **Working**: When file saving fails due to a `PermissionDenied` error, we create a temporary file in the same directory as the target file and writes the data to this temporary file. After, the contents of this file are copied to the original file using the `tee` command instead of `cp` or `mv`. This ensures that the ownership and permissions of the original file are preserved. This command is executed using `pkexec` which will prompt user for their password. **Custom Message**: The message displayed to the user in the prompt is automatically retrieved from the `org.zed.app.policy` file, which is located at `/usr/share/polkit-1/actions/`. This file should be installed during the setup process. While the policy file is optional, omitting it will cause the user to see the underlying command being executed rather than a user-friendly message. Currently, VSCode does not display the user-friendly message. The policy file must specify a unique binary, ensuring that only that binary can use the policy file. It cannot be as generic as a `/bin/bash`, as any software using bash to prompt will end up showing Zed’s custom message. To address this, we will create a custom bash script, as simple as the following, placed in `/usr/bin/zed/elevate.sh`. The script should have root ownership and should not reside in the home directory, since the policy file cannot resolve `$HOME`. ```sh #!/bin/bash eval "$@" ``` *IMPORTANT NOTE* Since copying the policy file and our script requires sudo privileges, the installation script will now prompt for the password at very end. Only on Linux, if `pexec` is installed. Screenshots: KDE with policy file: ![Screenshot from 2024-12-15 22-13-06](https://github.com/user-attachments/assets/b8bb7565-85df-4c95-bb10-82e50acf9b56) Gnome with policy file: ![Screenshot from 2024-12-15 22-21-48](https://github.com/user-attachments/assets/83d15056-a2bd-41d9-a01d-9b8954260381) Gnome without policy file: ![image](https://github.com/user-attachments/assets/66c39d02-eed4-4f09-886f-621b6d37ff43) VSCode: ![image](https://github.com/user-attachments/assets/949dc470-c3df-4e2f-8cc6-31babaee1d18) User declines the permission request: ![image](https://github.com/user-attachments/assets/c5cbf056-f6f9-43a8-8d88-f2b0597e14d6) Release Notes: - Fixed file saving with root ownership on Linux.
2024-12-19 22:16:01 +00:00