2022-10-11 20:03:36 +00:00
|
|
|
[package]
|
|
|
|
name = "fs"
|
|
|
|
version = "0.1.0"
|
|
|
|
edition = "2021"
|
2023-01-18 20:28:02 +00:00
|
|
|
publish = false
|
2024-01-27 12:51:16 +00:00
|
|
|
license = "GPL-3.0-or-later"
|
2024-01-23 16:40:30 +00:00
|
|
|
|
2024-03-05 17:01:17 +00:00
|
|
|
[lints]
|
|
|
|
workspace = true
|
|
|
|
|
2022-10-11 20:03:36 +00:00
|
|
|
[lib]
|
|
|
|
path = "src/fs.rs"
|
|
|
|
|
|
|
|
[dependencies]
|
2023-04-25 00:41:55 +00:00
|
|
|
anyhow.workspace = true
|
2024-03-02 00:00:55 +00:00
|
|
|
async-tar.workspace = true
|
2023-04-25 00:41:55 +00:00
|
|
|
async-trait.workspace = true
|
2024-06-17 23:27:42 +00:00
|
|
|
collections.workspace = true
|
2023-04-25 00:41:55 +00:00
|
|
|
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
|
2023-09-19 20:13:47 +00:00
|
|
|
git2.workspace = true
|
2024-07-23 21:59:55 +00:00
|
|
|
gpui.workspace = true
|
2024-06-17 23:27:42 +00:00
|
|
|
libc.workspace = true
|
2024-12-12 06:54:14 +00:00
|
|
|
log.workspace = true
|
2024-06-17 23:27:42 +00:00
|
|
|
parking_lot.workspace = true
|
|
|
|
paths.workspace = true
|
|
|
|
rope.workspace = true
|
2024-11-22 02:21:18 +00:00
|
|
|
proto.workspace = true
|
2023-04-25 00:41:55 +00:00
|
|
|
serde.workspace = true
|
|
|
|
serde_json.workspace = true
|
2024-06-17 23:27:42 +00:00
|
|
|
smol.workspace = true
|
|
|
|
tempfile.workspace = true
|
|
|
|
text.workspace = true
|
2023-06-27 11:28:50 +00:00
|
|
|
time.workspace = true
|
2024-06-17 23:27:42 +00:00
|
|
|
util.workspace = true
|
2023-10-02 22:20:47 +00:00
|
|
|
|
2024-03-09 06:18:44 +00:00
|
|
|
[target.'cfg(target_os = "macos")'.dependencies]
|
|
|
|
fsevent.workspace = true
|
2024-04-27 00:43:50 +00:00
|
|
|
objc = "0.2"
|
2024-08-29 04:57:26 +00:00
|
|
|
cocoa = "0.26"
|
2024-04-27 00:43:50 +00:00
|
|
|
|
2024-01-29 20:18:10 +00:00
|
|
|
[target.'cfg(not(target_os = "macos"))'.dependencies]
|
|
|
|
notify = "6.1.1"
|
|
|
|
|
2024-02-22 19:22:12 +00:00
|
|
|
[target.'cfg(target_os = "windows")'.dependencies]
|
2024-03-14 17:43:06 +00:00
|
|
|
windows.workspace = true
|
2024-02-22 19:22:12 +00:00
|
|
|
|
2024-11-11 17:39:05 +00:00
|
|
|
[target.'cfg(any(target_os = "linux", target_os = "freebsd"))'.dependencies]
|
2024-05-29 21:15:29 +00:00
|
|
|
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
|
2024-05-29 21:15:29 +00:00
|
|
|
|
2023-06-14 00:16:11 +00:00
|
|
|
[dev-dependencies]
|
2024-02-06 19:41:36 +00:00
|
|
|
gpui = { workspace = true, features = ["test-support"] }
|
2023-06-14 00:16:11 +00:00
|
|
|
|
2022-10-11 22:25:54 +00:00
|
|
|
[features]
|
2024-04-19 09:57:17 +00:00
|
|
|
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
|
|
|
|