mirror of
https://github.com/gitui-org/gitui
synced 2026-05-24 09:28:21 +00:00
revert clipboard feature on linux to fix static linux binary build (#261)
This commit is contained in:
parent
9be119a2f0
commit
e5c38e8d4a
8 changed files with 66 additions and 30 deletions
7
.github/workflows/ci.yml
vendored
7
.github/workflows/ci.yml
vendored
|
|
@ -70,10 +70,13 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get -qq install musl-tools
|
sudo apt-get -qq install musl-tools
|
||||||
- name: Build Debug
|
- name: Build Debug
|
||||||
run: cargo build --target=x86_64-unknown-linux-musl
|
run: |
|
||||||
|
make build-linux-musl-debug
|
||||||
|
./target/x86_64-unknown-linux-musl/debug/gitui --version
|
||||||
- name: Build Release
|
- name: Build Release
|
||||||
run: |
|
run: |
|
||||||
cargo build --release --target=x86_64-unknown-linux-musl
|
make build-linux-musl-release
|
||||||
|
./target/x86_64-unknown-linux-musl/release/gitui --version
|
||||||
|
|
||||||
rustfmt:
|
rustfmt:
|
||||||
name: Rustfmt
|
name: Rustfmt
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [0.10.1] - 2020-09-01
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- static linux binaries broke due to new clipboard feature which is disabled on linux for now ([#259](https://github.com/extrawurst/gitui/issues/259))
|
||||||
|
|
||||||
## [0.10.0] - 2020-08-29
|
## [0.10.0] - 2020-08-29
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
||||||
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -419,7 +419,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gitui"
|
name = "gitui"
|
||||||
version = "0.10.0"
|
version = "0.10.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"asyncgit",
|
"asyncgit",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "gitui"
|
name = "gitui"
|
||||||
version = "0.10.0"
|
version = "0.10.1"
|
||||||
authors = ["Stephan Dilly <dilly.stephan@gmail.com>"]
|
authors = ["Stephan Dilly <dilly.stephan@gmail.com>"]
|
||||||
description = "blazing fast terminal-ui for git"
|
description = "blazing fast terminal-ui for git"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
@ -40,7 +40,7 @@ serde = "1.0"
|
||||||
anyhow = "1.0.32"
|
anyhow = "1.0.32"
|
||||||
unicode-width = "0.1"
|
unicode-width = "0.1"
|
||||||
textwrap = "0.12"
|
textwrap = "0.12"
|
||||||
clipboard = "0.5"
|
clipboard = { version = "0.5", optional = true }
|
||||||
|
|
||||||
[target.'cfg(not(windows))'.dependencies]
|
[target.'cfg(not(windows))'.dependencies]
|
||||||
pprof = { version = "0.3", features = ["flamegraph"], optional = true }
|
pprof = { version = "0.3", features = ["flamegraph"], optional = true }
|
||||||
|
|
@ -49,7 +49,7 @@ pprof = { version = "0.3", features = ["flamegraph"], optional = true }
|
||||||
maintenance = { status = "actively-developed" }
|
maintenance = { status = "actively-developed" }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default=[]
|
default=["clipboard"]
|
||||||
timing=["scopetime/enabled"]
|
timing=["scopetime/enabled"]
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
|
|
|
||||||
9
Makefile
9
Makefile
|
|
@ -20,12 +20,17 @@ release-win: build-release
|
||||||
mkdir -p release
|
mkdir -p release
|
||||||
tar -C ./target/release/ -czvf ./release/gitui-win.tar.gz ./gitui.exe
|
tar -C ./target/release/ -czvf ./release/gitui-win.tar.gz ./gitui.exe
|
||||||
|
|
||||||
release-linux-musl:
|
release-linux-musl: build-linux-musl-release
|
||||||
cargo build --release --target=x86_64-unknown-linux-musl
|
|
||||||
strip target/x86_64-unknown-linux-musl/release/gitui
|
strip target/x86_64-unknown-linux-musl/release/gitui
|
||||||
mkdir -p release
|
mkdir -p release
|
||||||
tar -C ./target/x86_64-unknown-linux-musl/release/ -czvf ./release/gitui-linux-musl.tar.gz ./gitui
|
tar -C ./target/x86_64-unknown-linux-musl/release/ -czvf ./release/gitui-linux-musl.tar.gz ./gitui
|
||||||
|
|
||||||
|
build-linux-musl-debug:
|
||||||
|
cargo build --target=x86_64-unknown-linux-musl --no-default-features
|
||||||
|
|
||||||
|
build-linux-musl-release:
|
||||||
|
cargo build --release --target=x86_64-unknown-linux-musl --no-default-features
|
||||||
|
|
||||||
test:
|
test:
|
||||||
cargo test --workspace
|
cargo test --workspace
|
||||||
|
|
||||||
|
|
|
||||||
30
src/clipboard.rs
Normal file
30
src/clipboard.rs
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
use anyhow::Result;
|
||||||
|
#[cfg(feature = "clipboard")]
|
||||||
|
use clipboard::{ClipboardContext, ClipboardProvider};
|
||||||
|
|
||||||
|
#[cfg(feature = "clipboard")]
|
||||||
|
pub fn copy_string(string: String) -> Result<()> {
|
||||||
|
use anyhow::anyhow;
|
||||||
|
|
||||||
|
let mut ctx: ClipboardContext = ClipboardProvider::new()
|
||||||
|
.map_err(|_| anyhow!("failed to get access to clipboard"))?;
|
||||||
|
ctx.set_contents(string)
|
||||||
|
.map_err(|_| anyhow!("failed to set clipboard contents"))?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "clipboard"))]
|
||||||
|
pub fn copy_string(_string: String) -> Result<()> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "clipboard")]
|
||||||
|
pub fn is_supported() -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "clipboard"))]
|
||||||
|
pub fn is_supported() -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
@ -8,9 +8,9 @@ use crate::{
|
||||||
strings, try_or_popup,
|
strings, try_or_popup,
|
||||||
ui::{self, calc_scroll_top, style::SharedTheme},
|
ui::{self, calc_scroll_top, style::SharedTheme},
|
||||||
};
|
};
|
||||||
|
use anyhow::Result;
|
||||||
use asyncgit::{hash, sync, DiffLine, DiffLineType, FileDiff, CWD};
|
use asyncgit::{hash, sync, DiffLine, DiffLineType, FileDiff, CWD};
|
||||||
use bytesize::ByteSize;
|
use bytesize::ByteSize;
|
||||||
use clipboard::{ClipboardContext, ClipboardProvider};
|
|
||||||
use crossterm::event::Event;
|
use crossterm::event::Event;
|
||||||
use std::{borrow::Cow, cell::Cell, cmp, path::Path};
|
use std::{borrow::Cow, cell::Cell, cmp, path::Path};
|
||||||
use tui::{
|
use tui::{
|
||||||
|
|
@ -21,8 +21,6 @@ use tui::{
|
||||||
Frame,
|
Frame,
|
||||||
};
|
};
|
||||||
|
|
||||||
use anyhow::{anyhow, Result};
|
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct Current {
|
struct Current {
|
||||||
path: String,
|
path: String,
|
||||||
|
|
@ -244,18 +242,6 @@ impl DiffComponent {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn copy_string(string: String) -> Result<()> {
|
|
||||||
let mut ctx: ClipboardContext = ClipboardProvider::new()
|
|
||||||
.map_err(|_| {
|
|
||||||
anyhow!("failed to get access to clipboard")
|
|
||||||
})?;
|
|
||||||
ctx.set_contents(string).map_err(|_| {
|
|
||||||
anyhow!("failed to set clipboard contents")
|
|
||||||
})?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn copy_selection(&self) -> Result<()> {
|
fn copy_selection(&self) -> Result<()> {
|
||||||
if let Some(diff) = &self.diff {
|
if let Some(diff) = &self.diff {
|
||||||
let lines_to_copy: Vec<&str> = diff
|
let lines_to_copy: Vec<&str> = diff
|
||||||
|
|
@ -281,7 +267,9 @@ impl DiffComponent {
|
||||||
try_or_popup!(
|
try_or_popup!(
|
||||||
self,
|
self,
|
||||||
"copy to clipboard error:",
|
"copy to clipboard error:",
|
||||||
Self::copy_string(lines_to_copy.join("\n"))
|
crate::clipboard::copy_string(
|
||||||
|
lines_to_copy.join("\n")
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -616,11 +604,13 @@ impl Component for DiffComponent {
|
||||||
self.focused,
|
self.focused,
|
||||||
));
|
));
|
||||||
|
|
||||||
out.push(CommandInfo::new(
|
if crate::clipboard::is_supported() {
|
||||||
strings::commands::copy(&self.key_config),
|
out.push(CommandInfo::new(
|
||||||
true,
|
strings::commands::copy(&self.key_config),
|
||||||
self.focused,
|
true,
|
||||||
));
|
self.focused,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
out.push(
|
out.push(
|
||||||
CommandInfo::new(
|
CommandInfo::new(
|
||||||
|
|
@ -700,7 +690,9 @@ impl Component for DiffComponent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(true)
|
Ok(true)
|
||||||
} else if e == self.key_config.copy {
|
} else if e == self.key_config.copy
|
||||||
|
&& crate::clipboard::is_supported()
|
||||||
|
{
|
||||||
self.copy_selection()?;
|
self.copy_selection()?;
|
||||||
Ok(true)
|
Ok(true)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
#![warn(clippy::missing_const_for_fn)]
|
#![warn(clippy::missing_const_for_fn)]
|
||||||
|
|
||||||
mod app;
|
mod app;
|
||||||
|
mod clipboard;
|
||||||
mod cmdbar;
|
mod cmdbar;
|
||||||
mod components;
|
mod components;
|
||||||
mod input;
|
mod input;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue