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    ### 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>
This commit is contained in:
parent
e2d6b0deba
commit
7f54935324
39 changed files with 3760 additions and 157 deletions
|
@ -112,11 +112,64 @@ mv Cargo.toml.backup Cargo.toml
|
|||
popd
|
||||
echo "Bundled ${app_path}"
|
||||
|
||||
GIT_VERSION="v2.43.3"
|
||||
GIT_VERSION_SHA="fa29823"
|
||||
|
||||
function download_and_unpack() {
|
||||
local url=$1
|
||||
local path_to_unpack=$2
|
||||
local target_path=$3
|
||||
|
||||
temp_dir=$(mktemp -d)
|
||||
|
||||
if ! command -v curl &> /dev/null; then
|
||||
echo "curl is not installed. Please install curl to continue."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
curl --silent --fail --location "$url" | tar -xvz -C "$temp_dir" -f - $path_to_unpack
|
||||
|
||||
mv "$temp_dir/$path_to_unpack" "$target_path"
|
||||
|
||||
rm -rf "$temp_dir"
|
||||
}
|
||||
|
||||
function download_git() {
|
||||
local architecture=$1
|
||||
local target_binary=$2
|
||||
|
||||
tmp_dir=$(mktemp -d)
|
||||
pushd "$tmp_dir"
|
||||
|
||||
case "$architecture" in
|
||||
aarch64-apple-darwin)
|
||||
download_and_unpack "https://github.com/desktop/dugite-native/releases/download/${GIT_VERSION}/dugite-native-${GIT_VERSION}-${GIT_VERSION_SHA}-macOS-arm64.tar.gz" bin/git ./git
|
||||
;;
|
||||
x86_64-apple-darwin)
|
||||
download_and_unpack "https://github.com/desktop/dugite-native/releases/download/${GIT_VERSION}/dugite-native-${GIT_VERSION}-${GIT_VERSION_SHA}-macOS-x64.tar.gz" bin/git ./git
|
||||
;;
|
||||
universal)
|
||||
download_and_unpack "https://github.com/desktop/dugite-native/releases/download/${GIT_VERSION}/dugite-native-${GIT_VERSION}-${GIT_VERSION_SHA}-macOS-arm64.tar.gz" bin/git ./git_arm64
|
||||
download_and_unpack "https://github.com/desktop/dugite-native/releases/download/${GIT_VERSION}/dugite-native-${GIT_VERSION}-${GIT_VERSION_SHA}-macOS-x64.tar.gz" bin/git ./git_x64
|
||||
lipo -create ./git_arm64 ./git_x64 -output ./git
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported architecture: $architecture"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
popd
|
||||
|
||||
mv "${tmp_dir}/git" "${target_binary}"
|
||||
rm -rf "$tmp_dir"
|
||||
}
|
||||
|
||||
function prepare_binaries() {
|
||||
local architecture=$1
|
||||
local app_path=$2
|
||||
|
||||
echo "Uploading dSYMs for $architecture"
|
||||
echo "Unpacking dSYMs for $architecture"
|
||||
dsymutil --flat target/${architecture}/${target_dir}/Zed
|
||||
version="$(cargo metadata --no-deps --manifest-path crates/zed/Cargo.toml --offline --format-version=1 | jq -r '.packages | map(select(.name == "zed"))[0].version')"
|
||||
if [ "$channel" == "nightly" ]; then
|
||||
|
@ -139,14 +192,10 @@ function prepare_binaries() {
|
|||
cp target/${architecture}/${target_dir}/cli "${app_path}/Contents/MacOS/cli"
|
||||
}
|
||||
|
||||
if [ "$local_arch" = false ]; then
|
||||
prepare_binaries "aarch64-apple-darwin" "$app_path_aarch64"
|
||||
prepare_binaries "x86_64-apple-darwin" "$app_path_x64"
|
||||
fi
|
||||
|
||||
function sign_binaries() {
|
||||
local app_path=$1
|
||||
local architecture_dir=$2
|
||||
local architecture=$2
|
||||
local architecture_dir=$3
|
||||
echo "Copying WebRTC.framework into the frameworks folder"
|
||||
mkdir "${app_path}/Contents/Frameworks"
|
||||
if [ "$local_arch" = false ]; then
|
||||
|
@ -156,6 +205,9 @@ function sign_binaries() {
|
|||
cp -R target/${target_dir}/cli "${app_path}/Contents/MacOS/"
|
||||
fi
|
||||
|
||||
echo "Downloading git binary"
|
||||
download_git "${architecture}" "${app_path}/Contents/MacOS/git"
|
||||
|
||||
# Note: The app identifier for our development builds is the same as the app identifier for nightly.
|
||||
cp crates/${zed_crate}/contents/$channel/embedded.provisionprofile "${app_path}/Contents/"
|
||||
|
||||
|
@ -172,6 +224,7 @@ function sign_binaries() {
|
|||
# sequence of codesign commands modeled after this example: https://developer.apple.com/forums/thread/701514
|
||||
/usr/bin/codesign --deep --force --timestamp --sign "Zed Industries, Inc." "${app_path}/Contents/Frameworks/WebRTC.framework" -v
|
||||
/usr/bin/codesign --deep --force --timestamp --options runtime --sign "Zed Industries, Inc." "${app_path}/Contents/MacOS/cli" -v
|
||||
/usr/bin/codesign --deep --force --timestamp --options runtime --sign "Zed Industries, Inc." "${app_path}/Contents/MacOS/git" -v
|
||||
/usr/bin/codesign --deep --force --timestamp --options runtime --entitlements crates/${zed_crate}/resources/zed.entitlements --sign "Zed Industries, Inc." "${app_path}/Contents/MacOS/${zed_crate}" -v
|
||||
/usr/bin/codesign --force --timestamp --options runtime --entitlements crates/${zed_crate}/resources/zed.entitlements --sign "Zed Industries, Inc." "${app_path}" -v
|
||||
|
||||
|
@ -303,9 +356,12 @@ function sign_binaries() {
|
|||
}
|
||||
|
||||
if [ "$local_arch" = true ]; then
|
||||
sign_binaries "$app_path" "$local_target_triple"
|
||||
sign_binaries "$app_path" "$local_target_triple" "$local_target_triple"
|
||||
else
|
||||
# Create universal binary
|
||||
prepare_binaries "aarch64-apple-darwin" "$app_path_aarch64"
|
||||
prepare_binaries "x86_64-apple-darwin" "$app_path_x64"
|
||||
|
||||
cp -R "$app_path_x64" target/release/
|
||||
app_path=target/release/$(basename "$app_path_x64")
|
||||
lipo \
|
||||
|
@ -318,8 +374,8 @@ else
|
|||
target/{x86_64-apple-darwin,aarch64-apple-darwin}/${target_dir}/cli \
|
||||
-output \
|
||||
"${app_path}/Contents/MacOS/cli"
|
||||
sign_binaries "$app_path" "."
|
||||
sign_binaries "$app_path" "universal" "."
|
||||
|
||||
sign_binaries "$app_path_x64" "x86_64-apple-darwin"
|
||||
sign_binaries "$app_path_aarch64" "aarch64-apple-darwin"
|
||||
sign_binaries "$app_path_x64" "x86_64-apple-darwin" "x86_64-apple-darwin"
|
||||
sign_binaries "$app_path_aarch64" "aarch64-apple-darwin" "aarch64-apple-darwin"
|
||||
fi
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue