From f0d3e29283dff0ec052e90eea713362e67358446 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Tue, 1 Sep 2020 23:49:19 +0200 Subject: [PATCH 01/21] add first remotes test --- Cargo.lock | 37 ++++++++++++++++ asyncgit/Cargo.toml | 2 +- asyncgit/src/sync/mod.rs | 4 ++ asyncgit/src/sync/remotes.rs | 84 ++++++++++++++++++++++++++++++++++++ 4 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 asyncgit/src/sync/remotes.rs diff --git a/Cargo.lock b/Cargo.lock index ef27c69104..5939668ae3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -414,6 +414,8 @@ dependencies = [ "libc", "libgit2-sys", "log", + "openssl-probe", + "openssl-sys", "url", ] @@ -552,10 +554,26 @@ checksum = "0100ae90655025134424939f1f60e27e879460d451dff6afedde4f8226cbebfc" dependencies = [ "cc", "libc", + "libssh2-sys", "libz-sys", + "openssl-sys", "pkg-config", ] +[[package]] +name = "libssh2-sys" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca46220853ba1c512fc82826d0834d87b06bcd3c2a42241b7de72f3d2fe17056" +dependencies = [ + "cc", + "libc", + "libz-sys", + "openssl-sys", + "pkg-config", + "vcpkg", +] + [[package]] name = "libz-sys" version = "1.1.0" @@ -785,6 +803,25 @@ version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5" +[[package]] +name = "openssl-probe" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" + +[[package]] +name = "openssl-sys" +version = "0.9.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a842db4709b604f0fe5d1170ae3565899be2ad3d9cbc72dedc789ac0511f78de" +dependencies = [ + "autocfg", + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "parking_lot" version = "0.10.2" diff --git a/asyncgit/Cargo.toml b/asyncgit/Cargo.toml index e0c22963b6..1ded8a519b 100644 --- a/asyncgit/Cargo.toml +++ b/asyncgit/Cargo.toml @@ -13,7 +13,7 @@ keywords = ["git"] [dependencies] scopetime = { path = "../scopetime", version = "0.1" } -git2 = { version = "0.13.10", default-features = false } +git2 = { version = "0.13" } rayon-core = "1.8" crossbeam-channel = "0.4" log = "0.4" diff --git a/asyncgit/src/sync/mod.rs b/asyncgit/src/sync/mod.rs index 58b32148be..6b0d4d49d6 100644 --- a/asyncgit/src/sync/mod.rs +++ b/asyncgit/src/sync/mod.rs @@ -10,6 +10,7 @@ mod hooks; mod hunks; mod ignore; mod logwalker; +mod remotes; mod reset; mod stash; pub mod status; @@ -29,6 +30,9 @@ pub use hooks::{hooks_commit_msg, hooks_post_commit, HookResult}; pub use hunks::{reset_hunk, stage_hunk, unstage_hunk}; pub use ignore::add_to_ignore; pub use logwalker::LogWalker; +pub use remotes::{ + get_remotes, remote_fetch_master, remote_push_master, +}; pub use reset::{reset_stage, reset_workdir}; pub use stash::{get_stashes, stash_apply, stash_drop, stash_save}; pub use tags::{get_tags, CommitTags, Tags}; diff --git a/asyncgit/src/sync/remotes.rs b/asyncgit/src/sync/remotes.rs new file mode 100644 index 0000000000..7338b6b9b1 --- /dev/null +++ b/asyncgit/src/sync/remotes.rs @@ -0,0 +1,84 @@ +//! + +use crate::{error::Result, sync::utils}; +use git2::{Cred, FetchOptions, RemoteCallbacks}; +use scopetime::scope_time; + +/// +pub fn get_remotes(repo_path: &str) -> Result> { + scope_time!("get_remotes"); + + let repo = utils::repo(repo_path)?; + let remotes = repo.remotes()?; + let remotes: Vec = + remotes.iter().filter_map(|s| s).map(String::from).collect(); + + Ok(remotes) +} + +/// +pub fn remote_push_master(repo_path: &str) -> Result<()> { + scope_time!("remote_push_master"); + + let repo = utils::repo(repo_path)?; + let mut remote = repo.find_remote("origin")?; + + remote.push(&["refs/heads/master"], None)?; + + Ok(()) +} + +/// +pub fn remote_fetch_master(repo_path: &str) -> Result { + scope_time!("remote_fetch_master"); + + let repo = utils::repo(repo_path)?; + let mut remote = repo.find_remote("origin")?; + + let mut callbacks = RemoteCallbacks::new(); + callbacks.credentials(|url, username_from_url, allowed_types| { + log::debug!( + "creds: '{}' {:?} ({:?})", + url, + username_from_url, + allowed_types + ); + + Cred::ssh_key_from_agent( + username_from_url.expect("username not found"), + ) + }); + + let mut options = FetchOptions::new(); + options.remote_callbacks(callbacks); + + remote.fetch(&["master"], Some(&mut options), None)?; + + Ok(remote.stats().received_bytes()) +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::sync::tests::debug_cmd_print; + use tempfile::TempDir; + + #[test] + fn test_smoke() { + let td = TempDir::new().unwrap(); + + debug_cmd_print( + td.path().as_os_str().to_str().unwrap(), + "git clone https://github.com/extrawurst/brewdump.git", + ); + + let repo_path = td.path().join("brewdump"); + let repo_path = repo_path.as_os_str().to_str().unwrap(); + + let remotes = get_remotes(repo_path).unwrap(); + + assert_eq!(remotes, vec![String::from("origin")]); + + remote_fetch_master(repo_path).unwrap(); + } +} From b9de25c4425e361c32c57c806ff31eaba9dfa9dc Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Tue, 1 Sep 2020 23:54:38 +0200 Subject: [PATCH 02/21] libssl --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1607fbce55..a662d79c4b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,7 +64,7 @@ jobs: - name: Setup MUSL run: | - sudo apt-get -qq install musl-tools + sudo apt-get -qq install musl-tools libssl-dev - name: Build Debug run: | make build-linux-musl-debug From e4b6f32703491fb3ed8670484450fc24674d2cdc Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Wed, 2 Sep 2020 00:02:57 +0200 Subject: [PATCH 03/21] use docker image for musl build --- .github/workflows/ci.yml | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a662d79c4b..17ff84d07b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,24 +55,25 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - profile: minimal - target: x86_64-unknown-linux-musl + # - name: Install Rust + # uses: actions-rs/toolchain@v1 + # with: + # toolchain: stable + # profile: minimal + # target: x86_64-unknown-linux-musl - - name: Setup MUSL - run: | - sudo apt-get -qq install musl-tools libssl-dev - - name: Build Debug - run: | - make build-linux-musl-debug - ./target/x86_64-unknown-linux-musl/debug/gitui --version - - name: Build Release - run: | - make build-linux-musl-release - ./target/x86_64-unknown-linux-musl/release/gitui --version + - name: Build + uses: stevenleadbeater/rust-musl-builder@master + with: + args: /bin/bash -c "cargo build --release --target=x86_64-unknown-linux-musl --no-default-features" + # - name: Build Debug + # run: | + # make build-linux-musl-debug + # ./target/x86_64-unknown-linux-musl/debug/gitui --version + # - name: Build Release + # run: | + # make build-linux-musl-release + # ./target/x86_64-unknown-linux-musl/release/gitui --version rustfmt: name: Rustfmt From 9daac288bef7ceec5ebbd5584a1d12947bf82f4f Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Wed, 2 Sep 2020 00:12:48 +0200 Subject: [PATCH 04/21] use custom docker image --- .../actions/rust-musl-builder/.dockerignore | 2 + .github/actions/rust-musl-builder/Dockerfile | 67 +++++++++++++++++++ .../actions/rust-musl-builder/entrypoint.sh | 4 ++ .github/workflows/ci.yml | 8 ++- 4 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 .github/actions/rust-musl-builder/.dockerignore create mode 100644 .github/actions/rust-musl-builder/Dockerfile create mode 100644 .github/actions/rust-musl-builder/entrypoint.sh diff --git a/.github/actions/rust-musl-builder/.dockerignore b/.github/actions/rust-musl-builder/.dockerignore new file mode 100644 index 0000000000..2885679147 --- /dev/null +++ b/.github/actions/rust-musl-builder/.dockerignore @@ -0,0 +1,2 @@ +.git +.github \ No newline at end of file diff --git a/.github/actions/rust-musl-builder/Dockerfile b/.github/actions/rust-musl-builder/Dockerfile new file mode 100644 index 0000000000..7ec89d19ec --- /dev/null +++ b/.github/actions/rust-musl-builder/Dockerfile @@ -0,0 +1,67 @@ +FROM rust:slim + +LABEL name="rust-musl-builder" +LABEL version="1.0.0" +LABEL repository="https://github.com/juankaram/rust-musl-action" +LABEL homepage="https://github.com/juankaram/rust-musl-action" +LABEL maintainer="Juan Karam" + +LABEL com.github.actions.name="Rust MUSL Builder" +LABEL com.github.actions.description="Provides a Rust MUSL environment" +LABEL com.github.actions.icon="settings" +LABEL com.github.actions.color="orange" + +RUN apt-get update && apt-get install -y zip build-essential musl-tools pkg-config libssl-dev + +ENV BUILD_DIR=/build \ + OUTPUT_DIR=/output \ + RUST_BACKTRACE=1 \ + RUSTUP_HOME=/usr/local/rustup \ + CARGO_HOME=/usr/local/cargo \ + PATH=/usr/local/cargo/bin:$PATH \ + PREFIX=/toolchain \ + MUSL_VERSION=1.1.22 \ + OPENSSL_VERSION=1.1.0k \ + BUILD_TARGET=x86_64-unknown-linux-musl + +RUN mkdir -p /usr/local/cargo/bin \ + && mkdir -p $BUILD_DIR \ + && mkdir -p $OUTPUT_DIR \ + && mkdir -p $PREFIX + +WORKDIR $PREFIX + +ADD http://www.musl-libc.org/releases/musl-$MUSL_VERSION.tar.gz . +RUN tar -xvzf musl-$MUSL_VERSION.tar.gz \ + && cd musl-$MUSL_VERSION \ + && ./configure --prefix=$PREFIX \ + && make install \ + && cd .. + +ENV CC=$PREFIX/bin/musl-gcc \ + C_INCLUDE_PATH=$PREFIX/include/ \ + CPPFLAGS=-I$PREFIX/include \ + LDFLAGS=-L$PREFIX/lib + +ADD https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz . + +RUN echo "Building OpenSSL" \ + && tar -xzf "openssl-$OPENSSL_VERSION.tar.gz" \ + && cd openssl-$OPENSSL_VERSION \ + && ./Configure no-async no-afalgeng no-shared no-zlib -fPIC --prefix=$PREFIX --openssldir=$PREFIX/ssl linux-x86_64 \ + && make depend \ + && make install + +ENV OPENSSL_DIR=$PREFIX \ + OPENSSL_STATIC=true + +WORKDIR $BUILD_DIR + +RUN rustup self update && rustup update +RUN rustup target add $BUILD_TARGET +RUN rustup component add clippy-preview +RUN rustup component add rustfmt-preview +RUN cargo install cargo-release + +COPY entrypoint.sh /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/.github/actions/rust-musl-builder/entrypoint.sh b/.github/actions/rust-musl-builder/entrypoint.sh new file mode 100644 index 0000000000..3b8d63fd19 --- /dev/null +++ b/.github/actions/rust-musl-builder/entrypoint.sh @@ -0,0 +1,4 @@ +#!/bin/bash +set -e -u -o pipefail +cd $GITHUB_WORKSPACE +bash -c "$*" \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 17ff84d07b..66929bedd4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,9 +63,11 @@ jobs: # target: x86_64-unknown-linux-musl - name: Build - uses: stevenleadbeater/rust-musl-builder@master - with: - args: /bin/bash -c "cargo build --release --target=x86_64-unknown-linux-musl --no-default-features" + uses: ./.github/actions/rust-musl-builder + env: + BUILD_TARGET: x86_64-unknown-linux-musl + with: + args: /bin/bash -c "cargo build --release --target=x86_64-unknown-linux-musl --no-default-features" # - name: Build Debug # run: | # make build-linux-musl-debug From 5f849ffc11167792184d1fe146d2b5734ff8fef3 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Wed, 2 Sep 2020 00:24:16 +0200 Subject: [PATCH 05/21] next try --- .../actions/rust-musl-builder/.dockerignore | 2 - .github/actions/rust-musl-builder/Dockerfile | 67 --------- .../actions/rust-musl-builder/entrypoint.sh | 4 - .github/workflows/ci.yml | 140 +++++++++--------- 4 files changed, 69 insertions(+), 144 deletions(-) delete mode 100644 .github/actions/rust-musl-builder/.dockerignore delete mode 100644 .github/actions/rust-musl-builder/Dockerfile delete mode 100644 .github/actions/rust-musl-builder/entrypoint.sh diff --git a/.github/actions/rust-musl-builder/.dockerignore b/.github/actions/rust-musl-builder/.dockerignore deleted file mode 100644 index 2885679147..0000000000 --- a/.github/actions/rust-musl-builder/.dockerignore +++ /dev/null @@ -1,2 +0,0 @@ -.git -.github \ No newline at end of file diff --git a/.github/actions/rust-musl-builder/Dockerfile b/.github/actions/rust-musl-builder/Dockerfile deleted file mode 100644 index 7ec89d19ec..0000000000 --- a/.github/actions/rust-musl-builder/Dockerfile +++ /dev/null @@ -1,67 +0,0 @@ -FROM rust:slim - -LABEL name="rust-musl-builder" -LABEL version="1.0.0" -LABEL repository="https://github.com/juankaram/rust-musl-action" -LABEL homepage="https://github.com/juankaram/rust-musl-action" -LABEL maintainer="Juan Karam" - -LABEL com.github.actions.name="Rust MUSL Builder" -LABEL com.github.actions.description="Provides a Rust MUSL environment" -LABEL com.github.actions.icon="settings" -LABEL com.github.actions.color="orange" - -RUN apt-get update && apt-get install -y zip build-essential musl-tools pkg-config libssl-dev - -ENV BUILD_DIR=/build \ - OUTPUT_DIR=/output \ - RUST_BACKTRACE=1 \ - RUSTUP_HOME=/usr/local/rustup \ - CARGO_HOME=/usr/local/cargo \ - PATH=/usr/local/cargo/bin:$PATH \ - PREFIX=/toolchain \ - MUSL_VERSION=1.1.22 \ - OPENSSL_VERSION=1.1.0k \ - BUILD_TARGET=x86_64-unknown-linux-musl - -RUN mkdir -p /usr/local/cargo/bin \ - && mkdir -p $BUILD_DIR \ - && mkdir -p $OUTPUT_DIR \ - && mkdir -p $PREFIX - -WORKDIR $PREFIX - -ADD http://www.musl-libc.org/releases/musl-$MUSL_VERSION.tar.gz . -RUN tar -xvzf musl-$MUSL_VERSION.tar.gz \ - && cd musl-$MUSL_VERSION \ - && ./configure --prefix=$PREFIX \ - && make install \ - && cd .. - -ENV CC=$PREFIX/bin/musl-gcc \ - C_INCLUDE_PATH=$PREFIX/include/ \ - CPPFLAGS=-I$PREFIX/include \ - LDFLAGS=-L$PREFIX/lib - -ADD https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz . - -RUN echo "Building OpenSSL" \ - && tar -xzf "openssl-$OPENSSL_VERSION.tar.gz" \ - && cd openssl-$OPENSSL_VERSION \ - && ./Configure no-async no-afalgeng no-shared no-zlib -fPIC --prefix=$PREFIX --openssldir=$PREFIX/ssl linux-x86_64 \ - && make depend \ - && make install - -ENV OPENSSL_DIR=$PREFIX \ - OPENSSL_STATIC=true - -WORKDIR $BUILD_DIR - -RUN rustup self update && rustup update -RUN rustup target add $BUILD_TARGET -RUN rustup component add clippy-preview -RUN rustup component add rustfmt-preview -RUN cargo install cargo-release - -COPY entrypoint.sh /entrypoint.sh -ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/.github/actions/rust-musl-builder/entrypoint.sh b/.github/actions/rust-musl-builder/entrypoint.sh deleted file mode 100644 index 3b8d63fd19..0000000000 --- a/.github/actions/rust-musl-builder/entrypoint.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -set -e -u -o pipefail -cd $GITHUB_WORKSPACE -bash -c "$*" \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 66929bedd4..5e52bad73f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,47 +9,47 @@ on: branches: [ master ] jobs: - build: - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - rust: [nightly, stable] + # build: + # strategy: + # fail-fast: false + # matrix: + # os: [ubuntu-latest, macos-latest, windows-latest] + # rust: [nightly, stable] - runs-on: ${{ matrix.os }} - continue-on-error: ${{ matrix.rust == 'nightly' }} + # runs-on: ${{ matrix.os }} + # continue-on-error: ${{ matrix.rust == 'nightly' }} - steps: - - uses: actions/checkout@v2 + # steps: + # - uses: actions/checkout@v2 - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ matrix.rust }} - default: true - profile: minimal - components: clippy + # - name: Install Rust + # uses: actions-rs/toolchain@v1 + # with: + # toolchain: ${{ matrix.rust }} + # default: true + # profile: minimal + # components: clippy - - name: Install dependencies for clipboard access - if: matrix.os == 'ubuntu-latest' - run: | - sudo apt-get -qq install libxcb-shape0-dev libxcb-xfixes0-dev + # - name: Install dependencies for clipboard access + # if: matrix.os == 'ubuntu-latest' + # run: | + # sudo apt-get -qq install libxcb-shape0-dev libxcb-xfixes0-dev - - name: Build Debug - run: | - rustc --version - cargo build + # - name: Build Debug + # run: | + # rustc --version + # cargo build - - name: Run tests - run: make test + # - name: Run tests + # run: make test - - name: Run clippy - run: | - cargo clean - make clippy + # - name: Run clippy + # run: | + # cargo clean + # make clippy - - name: Build Release - run: make build-release + # - name: Build Release + # run: make build-release build-linux-musl: runs-on: ubuntu-latest @@ -63,11 +63,9 @@ jobs: # target: x86_64-unknown-linux-musl - name: Build - uses: ./.github/actions/rust-musl-builder - env: - BUILD_TARGET: x86_64-unknown-linux-musl - with: - args: /bin/bash -c "cargo build --release --target=x86_64-unknown-linux-musl --no-default-features" + uses: messense/rust-musl-cross:x86_64-musl + with: + args: /bin/bash -c "cargo build --release --no-default-features" # - name: Build Debug # run: | # make build-linux-musl-debug @@ -77,38 +75,38 @@ jobs: # make build-linux-musl-release # ./target/x86_64-unknown-linux-musl/release/gitui --version - rustfmt: - name: Rustfmt - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@master - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - components: rustfmt - - run: cargo fmt -- --check + # rustfmt: + # name: Rustfmt + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@master + # - name: Install Rust + # uses: actions-rs/toolchain@v1 + # with: + # toolchain: stable + # components: rustfmt + # - run: cargo fmt -- --check - sec: - name: Security audit - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/audit-check@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} + # sec: + # name: Security audit + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v2 + # - uses: actions-rs/audit-check@v1 + # with: + # token: ${{ secrets.GITHUB_TOKEN }} - log-test: - name: Changelog Test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@master - - name: Extract release notes - id: extract_release_notes - uses: ffurrer2/extract-release-notes@v1 - with: - release_notes_file: ./release-notes.txt - - uses: actions/upload-artifact@v1 - with: - name: release-notes.txt - path: ./release-notes.txt + # log-test: + # name: Changelog Test + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@master + # - name: Extract release notes + # id: extract_release_notes + # uses: ffurrer2/extract-release-notes@v1 + # with: + # release_notes_file: ./release-notes.txt + # - uses: actions/upload-artifact@v1 + # with: + # name: release-notes.txt + # path: ./release-notes.txt From 2d82033bab995610e8b32dfad9f5a7d749d40737 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Wed, 2 Sep 2020 00:31:58 +0200 Subject: [PATCH 06/21] next --- .github/workflows/ci.yml | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5e52bad73f..a3bda44046 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,25 +55,16 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - # - name: Install Rust - # uses: actions-rs/toolchain@v1 - # with: - # toolchain: stable - # profile: minimal - # target: x86_64-unknown-linux-musl - - - name: Build - uses: messense/rust-musl-cross:x86_64-musl + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: x86_64-unknown-linux-musl + override: true + - uses: actions-rs/cargo@v1 with: - args: /bin/bash -c "cargo build --release --no-default-features" - # - name: Build Debug - # run: | - # make build-linux-musl-debug - # ./target/x86_64-unknown-linux-musl/debug/gitui --version - # - name: Build Release - # run: | - # make build-linux-musl-release - # ./target/x86_64-unknown-linux-musl/release/gitui --version + use-cross: true + command: build + args: --release --target=x86_64-unknown-linux-musl # rustfmt: # name: Rustfmt From 17ad394179de53a2310e6cb81fc9fce3adb6d606 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Wed, 2 Sep 2020 00:47:59 +0200 Subject: [PATCH 07/21] can configure branch to fetch --- asyncgit/src/sync/mod.rs | 4 +--- asyncgit/src/sync/remotes.rs | 6 +++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/asyncgit/src/sync/mod.rs b/asyncgit/src/sync/mod.rs index 6b0d4d49d6..3fda789a1a 100644 --- a/asyncgit/src/sync/mod.rs +++ b/asyncgit/src/sync/mod.rs @@ -30,9 +30,7 @@ pub use hooks::{hooks_commit_msg, hooks_post_commit, HookResult}; pub use hunks::{reset_hunk, stage_hunk, unstage_hunk}; pub use ignore::add_to_ignore; pub use logwalker::LogWalker; -pub use remotes::{ - get_remotes, remote_fetch_master, remote_push_master, -}; +pub use remotes::{fetch_origin, get_remotes, remote_push_master}; pub use reset::{reset_stage, reset_workdir}; pub use stash::{get_stashes, stash_apply, stash_drop, stash_save}; pub use tags::{get_tags, CommitTags, Tags}; diff --git a/asyncgit/src/sync/remotes.rs b/asyncgit/src/sync/remotes.rs index 7338b6b9b1..2d6086dd26 100644 --- a/asyncgit/src/sync/remotes.rs +++ b/asyncgit/src/sync/remotes.rs @@ -29,7 +29,7 @@ pub fn remote_push_master(repo_path: &str) -> Result<()> { } /// -pub fn remote_fetch_master(repo_path: &str) -> Result { +pub fn fetch_origin(repo_path: &str, branch: &str) -> Result { scope_time!("remote_fetch_master"); let repo = utils::repo(repo_path)?; @@ -52,7 +52,7 @@ pub fn remote_fetch_master(repo_path: &str) -> Result { let mut options = FetchOptions::new(); options.remote_callbacks(callbacks); - remote.fetch(&["master"], Some(&mut options), None)?; + remote.fetch(&[branch], Some(&mut options), None)?; Ok(remote.stats().received_bytes()) } @@ -79,6 +79,6 @@ mod tests { assert_eq!(remotes, vec![String::from("origin")]); - remote_fetch_master(repo_path).unwrap(); + fetch_origin(repo_path, "master").unwrap(); } } From c4a280de3da234aece81b81841aa45308943a9eb Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Wed, 2 Sep 2020 00:48:05 +0200 Subject: [PATCH 08/21] use vendored ssl --- Cargo.lock | 10 ++++++++++ asyncgit/Cargo.toml | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 5939668ae3..a468f93c1c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -809,6 +809,15 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" +[[package]] +name = "openssl-src" +version = "111.10.2+1.1.1g" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a287fdb22e32b5b60624d4a5a7a02dbe82777f730ec0dbc42a0554326fef5a70" +dependencies = [ + "cc", +] + [[package]] name = "openssl-sys" version = "0.9.58" @@ -818,6 +827,7 @@ dependencies = [ "autocfg", "cc", "libc", + "openssl-src", "pkg-config", "vcpkg", ] diff --git a/asyncgit/Cargo.toml b/asyncgit/Cargo.toml index 1ded8a519b..621f07ebcb 100644 --- a/asyncgit/Cargo.toml +++ b/asyncgit/Cargo.toml @@ -13,7 +13,7 @@ keywords = ["git"] [dependencies] scopetime = { path = "../scopetime", version = "0.1" } -git2 = { version = "0.13" } +git2 = { version = "0.13", features = ["vendored-openssl"] } rayon-core = "1.8" crossbeam-channel = "0.4" log = "0.4" From 8b3abc6bfbe0729b2e2d65a524df5504c5ffd662 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Wed, 2 Sep 2020 00:55:33 +0200 Subject: [PATCH 09/21] . --- .github/workflows/ci.yml | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a3bda44046..0c8b4a35da 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,17 +54,23 @@ jobs: build-linux-musl: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - name: Install Rust + uses: actions-rs/toolchain@v1 with: toolchain: stable + profile: minimal target: x86_64-unknown-linux-musl - override: true - - uses: actions-rs/cargo@v1 - with: - use-cross: true - command: build - args: --release --target=x86_64-unknown-linux-musl + - name: Setup MUSL + run: | + sudo apt-get -qq install musl-tools libssl-dev + - name: Build Debug + run: | + make build-linux-musl-debug + ./target/x86_64-unknown-linux-musl/debug/gitui --version + - name: Build Release + run: | + make build-linux-musl-release + ./target/x86_64-unknown-linux-musl/release/gitui --version # rustfmt: # name: Rustfmt From feaf9386207177fd9e68fa65114c5534a7a6d536 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Wed, 2 Sep 2020 00:57:35 +0200 Subject: [PATCH 10/21] . --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0c8b4a35da..f6d0859a11 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,6 +54,7 @@ jobs: build-linux-musl: runs-on: ubuntu-latest steps: + - uses: actions/checkout@master - name: Install Rust uses: actions-rs/toolchain@v1 with: From 39dd49b6d0e604d584d4febcc139f624b7617035 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Wed, 2 Sep 2020 01:02:17 +0200 Subject: [PATCH 11/21] add unittests aswell --- .github/workflows/ci.yml | 3 +++ Makefile | 3 +++ 2 files changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f6d0859a11..ea70db543b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,6 +72,9 @@ jobs: run: | make build-linux-musl-release ./target/x86_64-unknown-linux-musl/release/gitui --version + - name: Test + run: | + make test-linux-musl # rustfmt: # name: Rustfmt diff --git a/Makefile b/Makefile index fa537a24bf..a0b61e3983 100644 --- a/Makefile +++ b/Makefile @@ -31,6 +31,9 @@ build-linux-musl-debug: build-linux-musl-release: cargo build --release --target=x86_64-unknown-linux-musl --no-default-features +test-linux-musl: + cargo test --workspace --target=x86_64-unknown-linux-musl + test: cargo test --workspace From ec75703459e73e693a32017654d37db23e77458d Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Wed, 2 Sep 2020 01:03:23 +0200 Subject: [PATCH 12/21] is this apt dep needed? --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ea70db543b..aaeaa9072c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,7 +63,7 @@ jobs: target: x86_64-unknown-linux-musl - name: Setup MUSL run: | - sudo apt-get -qq install musl-tools libssl-dev + sudo apt-get -qq install musl-tools - name: Build Debug run: | make build-linux-musl-debug From 58c873931a42b3ba11ae16842e96a7fe8b8513a5 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Wed, 2 Sep 2020 01:10:49 +0200 Subject: [PATCH 13/21] no clipboard feature on test run --- .github/workflows/cd.yml | 2 +- .github/workflows/ci.yml | 1 - Makefile | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 1036b5ec95..d30f32dd84 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -11,8 +11,8 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] - runs-on: ${{ matrix.os }} + steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aaeaa9072c..8e174f1251 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,6 @@ jobs: # matrix: # os: [ubuntu-latest, macos-latest, windows-latest] # rust: [nightly, stable] - # runs-on: ${{ matrix.os }} # continue-on-error: ${{ matrix.rust == 'nightly' }} diff --git a/Makefile b/Makefile index a0b61e3983..ac0688366c 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ build-linux-musl-release: cargo build --release --target=x86_64-unknown-linux-musl --no-default-features test-linux-musl: - cargo test --workspace --target=x86_64-unknown-linux-musl + cargo test --workspace --target=x86_64-unknown-linux-musl --no-default-features test: cargo test --workspace From 5327deba085ce2044db2b82b9a8c8fb2b73aac59 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Wed, 2 Sep 2020 01:26:34 +0200 Subject: [PATCH 14/21] support pushing --- asyncgit/src/sync/mod.rs | 4 +++- asyncgit/src/sync/remotes.rs | 33 ++++++++++++++++++++++++++------- src/components/changes.rs | 5 +++++ src/keys.rs | 2 ++ src/tabs/status.rs | 26 ++++++++++++++++++++++++++ 5 files changed, 62 insertions(+), 8 deletions(-) diff --git a/asyncgit/src/sync/mod.rs b/asyncgit/src/sync/mod.rs index 3fda789a1a..4eb97b6967 100644 --- a/asyncgit/src/sync/mod.rs +++ b/asyncgit/src/sync/mod.rs @@ -30,7 +30,9 @@ pub use hooks::{hooks_commit_msg, hooks_post_commit, HookResult}; pub use hunks::{reset_hunk, stage_hunk, unstage_hunk}; pub use ignore::add_to_ignore; pub use logwalker::LogWalker; -pub use remotes::{fetch_origin, get_remotes, remote_push_master}; +pub use remotes::{ + fetch_origin, get_remotes, push_origin, remote_push_master, +}; pub use reset::{reset_stage, reset_workdir}; pub use stash::{get_stashes, stash_apply, stash_drop, stash_save}; pub use tags::{get_tags, CommitTags, Tags}; diff --git a/asyncgit/src/sync/remotes.rs b/asyncgit/src/sync/remotes.rs index 2d6086dd26..3598c360b5 100644 --- a/asyncgit/src/sync/remotes.rs +++ b/asyncgit/src/sync/remotes.rs @@ -1,7 +1,7 @@ //! use crate::{error::Result, sync::utils}; -use git2::{Cred, FetchOptions, RemoteCallbacks}; +use git2::{Cred, FetchOptions, PushOptions, RemoteCallbacks}; use scopetime::scope_time; /// @@ -35,6 +35,30 @@ pub fn fetch_origin(repo_path: &str, branch: &str) -> Result { let repo = utils::repo(repo_path)?; let mut remote = repo.find_remote("origin")?; + let mut options = FetchOptions::new(); + options.remote_callbacks(remote_callbacks()); + + remote.fetch(&[branch], Some(&mut options), None)?; + + Ok(remote.stats().received_bytes()) +} + +/// +pub fn push_origin(repo_path: &str, branch: &str) -> Result { + scope_time!("push_origin"); + + let repo = utils::repo(repo_path)?; + let mut remote = repo.find_remote("origin")?; + + let mut options = PushOptions::new(); + options.remote_callbacks(remote_callbacks()); + + remote.push(&[branch], Some(&mut options))?; + + Ok(remote.stats().received_bytes()) +} + +fn remote_callbacks<'a>() -> RemoteCallbacks<'a> { let mut callbacks = RemoteCallbacks::new(); callbacks.credentials(|url, username_from_url, allowed_types| { log::debug!( @@ -49,12 +73,7 @@ pub fn fetch_origin(repo_path: &str, branch: &str) -> Result { ) }); - let mut options = FetchOptions::new(); - options.remote_callbacks(callbacks); - - remote.fetch(&[branch], Some(&mut options), None)?; - - Ok(remote.stats().received_bytes()) + callbacks } #[cfg(test)] diff --git a/src/components/changes.rs b/src/components/changes.rs index 396afda99e..801735d939 100644 --- a/src/components/changes.rs +++ b/src/components/changes.rs @@ -64,6 +64,11 @@ impl ChangesComponent { Ok(()) } + /// + pub fn branch_name(&mut self) -> Option { + self.branch_name.lookup().ok() + } + /// pub fn set_items(&mut self, list: &[StatusItem]) -> Result<()> { self.files.update(list)?; diff --git a/src/keys.rs b/src/keys.rs index 41c1e7ffd5..24d0ea1ee9 100644 --- a/src/keys.rs +++ b/src/keys.rs @@ -60,6 +60,7 @@ pub struct KeyConfig { pub commit_amend: KeyEvent, pub copy: KeyEvent, pub create_branch: KeyEvent, + pub push: KeyEvent, } #[rustfmt::skip] @@ -109,6 +110,7 @@ impl Default for KeyConfig { commit_amend: KeyEvent { code: KeyCode::Char('a'), modifiers: KeyModifiers::CONTROL}, copy: KeyEvent { code: KeyCode::Char('y'), modifiers: KeyModifiers::empty()}, create_branch: KeyEvent { code: KeyCode::Char('b'), modifiers: KeyModifiers::empty()}, + push: KeyEvent { code: KeyCode::Char('p'), modifiers: KeyModifiers::empty()}, } } } diff --git a/src/tabs/status.rs b/src/tabs/status.rs index 120f159ac1..c416de2797 100644 --- a/src/tabs/status.rs +++ b/src/tabs/status.rs @@ -323,6 +323,29 @@ impl Status { true } } + + fn push(&mut self) { + if let Some(branch) = self.index_wd.branch_name() { + match sync::push_origin(CWD, branch.as_str()) { + Err(e) => { + self.queue.borrow_mut().push_back( + InternalEvent::ShowErrorMsg(format!( + "push failed:\n{}", + e + )), + ); + } + Ok(bytes) => { + self.queue.borrow_mut().push_back( + InternalEvent::ShowErrorMsg(format!( + "pushed: {} bytes", + bytes + )), + ); + } + } + } + } } impl Component for Status { @@ -451,6 +474,9 @@ impl Component for Status { .borrow_mut() .push_back(InternalEvent::CreateBranch); Ok(true) + } else if k == self.key_config.push { + self.push(); + Ok(true) } else { Ok(false) }; From 9b264573c6e4477297918bd2d1baac61e71af2a5 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Wed, 2 Sep 2020 01:33:54 +0200 Subject: [PATCH 15/21] fix pushing --- asyncgit/src/sync/remotes.rs | 4 ++-- src/tabs/status.rs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/asyncgit/src/sync/remotes.rs b/asyncgit/src/sync/remotes.rs index 3598c360b5..916b4f876d 100644 --- a/asyncgit/src/sync/remotes.rs +++ b/asyncgit/src/sync/remotes.rs @@ -44,7 +44,7 @@ pub fn fetch_origin(repo_path: &str, branch: &str) -> Result { } /// -pub fn push_origin(repo_path: &str, branch: &str) -> Result { +pub fn push_origin(repo_path: &str, branch: &str) -> Result<()> { scope_time!("push_origin"); let repo = utils::repo(repo_path)?; @@ -55,7 +55,7 @@ pub fn push_origin(repo_path: &str, branch: &str) -> Result { remote.push(&[branch], Some(&mut options))?; - Ok(remote.stats().received_bytes()) + Ok(()) } fn remote_callbacks<'a>() -> RemoteCallbacks<'a> { diff --git a/src/tabs/status.rs b/src/tabs/status.rs index c416de2797..17485c929b 100644 --- a/src/tabs/status.rs +++ b/src/tabs/status.rs @@ -326,6 +326,7 @@ impl Status { fn push(&mut self) { if let Some(branch) = self.index_wd.branch_name() { + let branch = format!("refs/heads/{}", branch); match sync::push_origin(CWD, branch.as_str()) { Err(e) => { self.queue.borrow_mut().push_back( @@ -335,11 +336,10 @@ impl Status { )), ); } - Ok(bytes) => { + Ok(_) => { self.queue.borrow_mut().push_back( InternalEvent::ShowErrorMsg(format!( - "pushed: {} bytes", - bytes + "pushed", )), ); } From 7cb845818c09440c46da30c0ac55168c6861ffd6 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Wed, 2 Sep 2020 01:39:30 +0200 Subject: [PATCH 16/21] non error dialog when push done --- src/app.rs | 9 +++++++-- src/components/msg.rs | 19 +++++++++++++++---- src/queue.rs | 2 ++ src/strings.rs | 3 +++ src/tabs/status.rs | 6 +++--- 5 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/app.rs b/src/app.rs index eb7958ff5a..adb6f1e411 100644 --- a/src/app.rs +++ b/src/app.rs @@ -256,7 +256,7 @@ impl App { let msg = format!("failed to launch editor:\n{}", e); log::error!("{}", msg.as_str()); - self.msg.show_msg(msg.as_str())?; + self.msg.show_error(msg.as_str())?; } self.requires_redraw.set(true); @@ -454,7 +454,12 @@ impl App { flags.insert(NeedsUpdate::COMMANDS); } InternalEvent::ShowErrorMsg(msg) => { - self.msg.show_msg(msg.as_str())?; + self.msg.show_error(msg.as_str())?; + flags + .insert(NeedsUpdate::ALL | NeedsUpdate::COMMANDS); + } + InternalEvent::ShowInfoMsg(msg) => { + self.msg.show_info(msg.as_str())?; flags .insert(NeedsUpdate::ALL | NeedsUpdate::COMMANDS); } diff --git a/src/components/msg.rs b/src/components/msg.rs index 6320b3f610..d3c6e87bc0 100644 --- a/src/components/msg.rs +++ b/src/components/msg.rs @@ -14,6 +14,7 @@ use tui::{ use ui::style::SharedTheme; pub struct MsgComponent { + title: String, msg: String, visible: bool, theme: SharedTheme, @@ -39,9 +40,7 @@ impl DrawableComponent for MsgComponent { Paragraph::new(txt.iter()) .block( Block::default() - .title(&strings::msg_title_error( - &self.key_config, - )) + .title(self.title.as_str()) .title_style(self.theme.text_danger()) .borders(Borders::ALL) .border_type(BorderType::Thick), @@ -104,14 +103,26 @@ impl MsgComponent { key_config: SharedKeyConfig, ) -> Self { Self { + title: String::new(), msg: String::new(), visible: false, theme, key_config, } } + + /// + pub fn show_error(&mut self, msg: &str) -> Result<()> { + self.title = strings::msg_title_error(&self.key_config); + self.msg = msg.to_string(); + self.show()?; + + Ok(()) + } + /// - pub fn show_msg(&mut self, msg: &str) -> Result<()> { + pub fn show_info(&mut self, msg: &str) -> Result<()> { + self.title = strings::msg_title_info(&self.key_config); self.msg = msg.to_string(); self.show()?; diff --git a/src/queue.rs b/src/queue.rs index 3e3478f3ff..982584890c 100644 --- a/src/queue.rs +++ b/src/queue.rs @@ -39,6 +39,8 @@ pub enum InternalEvent { /// ShowErrorMsg(String), /// + ShowInfoMsg(String), + /// Update(NeedsUpdate), /// open commit msg input OpenCommit, diff --git a/src/strings.rs b/src/strings.rs index 077708777d..0f411bef82 100644 --- a/src/strings.rs +++ b/src/strings.rs @@ -40,6 +40,9 @@ pub fn msg_opening_editor(_key_config: &SharedKeyConfig) -> String { pub fn msg_title_error(_key_config: &SharedKeyConfig) -> String { "Error".to_string() } +pub fn msg_title_info(_key_config: &SharedKeyConfig) -> String { + "Info".to_string() +} pub fn commit_title(_key_config: &SharedKeyConfig) -> String { "Commit".to_string() } diff --git a/src/tabs/status.rs b/src/tabs/status.rs index 17485c929b..baf2ccfd84 100644 --- a/src/tabs/status.rs +++ b/src/tabs/status.rs @@ -338,9 +338,9 @@ impl Status { } Ok(_) => { self.queue.borrow_mut().push_back( - InternalEvent::ShowErrorMsg(format!( - "pushed", - )), + InternalEvent::ShowInfoMsg( + format!("pushed",), + ), ); } } From 2c6458041dab04397dd51a9e87f1fa4435f4957a Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Wed, 2 Sep 2020 01:45:09 +0200 Subject: [PATCH 17/21] show push cmd in bar --- asyncgit/src/cached/branchname.rs | 5 +++++ src/components/changes.rs | 4 ++-- src/strings.rs | 7 +++++++ src/tabs/status.rs | 7 ++++++- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/asyncgit/src/cached/branchname.rs b/asyncgit/src/cached/branchname.rs index e5df31aa7b..8464458aa7 100644 --- a/asyncgit/src/cached/branchname.rs +++ b/asyncgit/src/cached/branchname.rs @@ -32,6 +32,11 @@ impl BranchName { self.fetch(current_head) } + /// + pub fn last(&self) -> Option { + self.last_result.as_ref().map(|last| last.1.clone()) + } + fn fetch(&mut self, head: Head) -> Result { let name = sync::get_branch_name(self.repo_path.as_str())?; self.last_result = Some((head, name.clone())); diff --git a/src/components/changes.rs b/src/components/changes.rs index 801735d939..acdf5e3604 100644 --- a/src/components/changes.rs +++ b/src/components/changes.rs @@ -65,8 +65,8 @@ impl ChangesComponent { } /// - pub fn branch_name(&mut self) -> Option { - self.branch_name.lookup().ok() + pub fn branch_name(&self) -> Option { + self.branch_name.last() } /// diff --git a/src/strings.rs b/src/strings.rs index 0f411bef82..4f8da04734 100644 --- a/src/strings.rs +++ b/src/strings.rs @@ -599,4 +599,11 @@ pub mod commands { CMD_GROUP_GENERAL, ) } + pub fn status_push(key_config: &SharedKeyConfig) -> CommandText { + CommandText::new( + format!("Push [{}]", get_hint(key_config.push),), + "push to origin", + CMD_GROUP_GENERAL, + ) + } } diff --git a/src/tabs/status.rs b/src/tabs/status.rs index baf2ccfd84..fb56d8ab40 100644 --- a/src/tabs/status.rs +++ b/src/tabs/status.rs @@ -324,7 +324,7 @@ impl Status { } } - fn push(&mut self) { + fn push(&self) { if let Some(branch) = self.index_wd.branch_name() { let branch = format!("refs/heads/{}", branch); match sync::push_origin(CWD, branch.as_str()) { @@ -392,6 +392,11 @@ impl Component for Status { true, true, )); + out.push(CommandInfo::new( + strings::commands::status_push(&self.key_config), + self.index_wd.branch_name().is_some(), + true, + )); out.push( CommandInfo::new( From d969c6a68bc32887ab62e0e33d7c2c053961c233 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Wed, 2 Sep 2020 01:46:43 +0200 Subject: [PATCH 18/21] fix unittests --- assets/vim_style_key_config.ron | 1 + 1 file changed, 1 insertion(+) diff --git a/assets/vim_style_key_config.ron b/assets/vim_style_key_config.ron index 129c76e630..6e4735b23d 100644 --- a/assets/vim_style_key_config.ron +++ b/assets/vim_style_key_config.ron @@ -59,4 +59,5 @@ commit_amend: ( code: Char('A'), modifiers: ( bits: 0,),), copy: ( code: Char('y'), modifiers: ( bits: 0,),), create_branch: ( code: Char('b'), modifiers: ( bits: 0,),), + push: ( code: Char('p'), modifiers: ( bits: 0,),), ) From 0d9dffa65307f9c3edada6a8ae8e2855bb88774b Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Wed, 2 Sep 2020 01:48:40 +0200 Subject: [PATCH 19/21] clippy fixes --- src/tabs/status.rs | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/src/tabs/status.rs b/src/tabs/status.rs index fb56d8ab40..69ba6c79da 100644 --- a/src/tabs/status.rs +++ b/src/tabs/status.rs @@ -327,22 +327,17 @@ impl Status { fn push(&self) { if let Some(branch) = self.index_wd.branch_name() { let branch = format!("refs/heads/{}", branch); - match sync::push_origin(CWD, branch.as_str()) { - Err(e) => { - self.queue.borrow_mut().push_back( - InternalEvent::ShowErrorMsg(format!( - "push failed:\n{}", - e - )), - ); - } - Ok(_) => { - self.queue.borrow_mut().push_back( - InternalEvent::ShowInfoMsg( - format!("pushed",), - ), - ); - } + if let Err(e) = sync::push_origin(CWD, branch.as_str()) { + self.queue.borrow_mut().push_back( + InternalEvent::ShowErrorMsg(format!( + "push failed:\n{}", + e + )), + ); + } else { + self.queue.borrow_mut().push_back( + InternalEvent::ShowInfoMsg("pushed".to_string()), + ); } } } From 9ad8903155c72d4d0598eb148a132747c6e1dd5f Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Wed, 2 Sep 2020 01:49:49 +0200 Subject: [PATCH 20/21] clippy fix --- src/clipboard.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/clipboard.rs b/src/clipboard.rs index b0c3e42ff4..2828ff6577 100644 --- a/src/clipboard.rs +++ b/src/clipboard.rs @@ -20,7 +20,7 @@ pub fn copy_string(_string: String) -> Result<()> { } #[cfg(feature = "clipboard")] -pub fn is_supported() -> bool { +pub const fn is_supported() -> bool { true } From b973d61c6cfe722d1a7ea0d7340573ad4ffd1fc4 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Wed, 2 Sep 2020 01:56:41 +0200 Subject: [PATCH 21/21] enable all ci again --- .github/workflows/ci.yml | 132 +++++++++++++++++++-------------------- 1 file changed, 66 insertions(+), 66 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8e174f1251..76178a8b83 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,46 +9,46 @@ on: branches: [ master ] jobs: - # build: - # strategy: - # fail-fast: false - # matrix: - # os: [ubuntu-latest, macos-latest, windows-latest] - # rust: [nightly, stable] - # runs-on: ${{ matrix.os }} - # continue-on-error: ${{ matrix.rust == 'nightly' }} + build: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + rust: [nightly, stable] + runs-on: ${{ matrix.os }} + continue-on-error: ${{ matrix.rust == 'nightly' }} - # steps: - # - uses: actions/checkout@v2 + steps: + - uses: actions/checkout@v2 - # - name: Install Rust - # uses: actions-rs/toolchain@v1 - # with: - # toolchain: ${{ matrix.rust }} - # default: true - # profile: minimal - # components: clippy + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.rust }} + default: true + profile: minimal + components: clippy - # - name: Install dependencies for clipboard access - # if: matrix.os == 'ubuntu-latest' - # run: | - # sudo apt-get -qq install libxcb-shape0-dev libxcb-xfixes0-dev + - name: Install dependencies for clipboard access + if: matrix.os == 'ubuntu-latest' + run: | + sudo apt-get -qq install libxcb-shape0-dev libxcb-xfixes0-dev - # - name: Build Debug - # run: | - # rustc --version - # cargo build + - name: Build Debug + run: | + rustc --version + cargo build - # - name: Run tests - # run: make test + - name: Run tests + run: make test - # - name: Run clippy - # run: | - # cargo clean - # make clippy + - name: Run clippy + run: | + cargo clean + make clippy - # - name: Build Release - # run: make build-release + - name: Build Release + run: make build-release build-linux-musl: runs-on: ubuntu-latest @@ -75,38 +75,38 @@ jobs: run: | make test-linux-musl - # rustfmt: - # name: Rustfmt - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@master - # - name: Install Rust - # uses: actions-rs/toolchain@v1 - # with: - # toolchain: stable - # components: rustfmt - # - run: cargo fmt -- --check + rustfmt: + name: Rustfmt + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + components: rustfmt + - run: cargo fmt -- --check - # sec: - # name: Security audit - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v2 - # - uses: actions-rs/audit-check@v1 - # with: - # token: ${{ secrets.GITHUB_TOKEN }} + sec: + name: Security audit + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/audit-check@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} - # log-test: - # name: Changelog Test - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@master - # - name: Extract release notes - # id: extract_release_notes - # uses: ffurrer2/extract-release-notes@v1 - # with: - # release_notes_file: ./release-notes.txt - # - uses: actions/upload-artifact@v1 - # with: - # name: release-notes.txt - # path: ./release-notes.txt + log-test: + name: Changelog Test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Extract release notes + id: extract_release_notes + uses: ffurrer2/extract-release-notes@v1 + with: + release_notes_file: ./release-notes.txt + - uses: actions/upload-artifact@v1 + with: + name: release-notes.txt + path: ./release-notes.txt