Skip to content

support for openpgp, ssh, x509 signatures with tests #1538

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/linux-git-devel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.74
toolchain: "1.80"
override: true

- uses: actions/checkout@v4
Expand All @@ -66,6 +66,9 @@ jobs:
run: |
export TEST_GIT="$PWD"/git-master/git
export TEST_GIT_EXEC_PATH=$(dirname "$TEST_GIT")
export TEST_GPG=$(which gpg)
export TEST_GPGSM=$(which gpgsm)
export TEST_SSH_KEYGEN=$(which ssh-keygen)
(cd git-branchless && cargo test --all-features --examples --tests --workspace --no-fail-fast)

- name: Run Rust tests on Git `next`
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.74
toolchain: "1.80"
override: true

- name: Cache dependencies
Expand All @@ -89,6 +89,9 @@ jobs:
run: |
export TEST_GIT="$PWD"/git
export TEST_GIT_EXEC_PATH=$(dirname "$TEST_GIT")
export TEST_GPG=$(which gpg)
export TEST_GPGSM=$(which gpgsm)
export TEST_SSH_KEYGEN=$(which ssh-keygen)
cargo test --all-features --examples --tests --workspace --no-fail-fast

# Note that `--doc` can't be combined with other tests.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.74
toolchain: "1.80"
override: true

- name: Cache dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.74
toolchain: "1.80"
override: true

- name: Cache dependencies
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- `scm-record` upgraded to [v0.5.0](https://github.com/arxanas/scm-record/releases/tag/v0.5.0).
- (#1463): `git switch` now accepts a revset whose sole head will be checked out
- BREAKING: The minimum supported Rust version (MSRV) is now 1.80.

## [v0.10.0] - 2024-10-10

Expand Down
72 changes: 66 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ git-branchless-submit = { version = "0.10.0", path = "git-branchless-submit" }
git-branchless-test = { version = "0.10.0", path = "git-branchless-test" }
git-branchless-undo = { version = "0.10.0", path = "git-branchless-undo" }
git2 = { version = "0.20.0", default-features = false }
git2-ext = "0.6.3"
glob = "0.3.2"
indexmap = "2.7.1"
indicatif = { version = "0.17.11", features = ["improved_unicode"] }
Expand Down
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion git-branchless-hook/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
clippy::clone_on_ref_ptr,
clippy::dbg_macro
)]
#![allow(clippy::too_many_arguments, clippy::blocks_in_if_conditions)]
#![allow(clippy::too_many_arguments, clippy::blocks_in_conditions)]

use std::fmt::Write;
use std::fs::File;
Expand Down
2 changes: 1 addition & 1 deletion git-branchless-init/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
clippy::clone_on_ref_ptr,
clippy::dbg_macro
)]
#![allow(clippy::too_many_arguments, clippy::blocks_in_if_conditions)]
#![allow(clippy::too_many_arguments, clippy::blocks_in_conditions)]

use std::fmt::Write;
use std::io::{stdin, stdout, BufRead, BufReader, Write as WriteIo};
Expand Down
2 changes: 1 addition & 1 deletion git-branchless-invoke/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
clippy::clone_on_ref_ptr,
clippy::dbg_macro
)]
#![allow(clippy::too_many_arguments, clippy::blocks_in_if_conditions)]
#![allow(clippy::too_many_arguments, clippy::blocks_in_conditions)]

use std::any::Any;
use std::collections::HashMap;
Expand Down
6 changes: 5 additions & 1 deletion git-branchless-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ keywords = ["git"]
license = "MIT OR Apache-2.0"
name = "git-branchless-lib"
repository = "https://github.com/arxanas/git-branchless"
rust-version = "1.64.0"
rust-version = "1.80"
version = "0.10.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand All @@ -17,6 +17,9 @@ name = "branchless"
[features]
default = []
integration-test-bin = []
test_gpg = []
test_ssh = []
test_x509 = []

[[bench]]
harness = false
Expand Down Expand Up @@ -56,6 +59,7 @@ eden_dag = { workspace = true }
eyre = { workspace = true }
futures = { workspace = true }
git2 = { workspace = true }
git2-ext = { workspace = true }
indicatif = { workspace = true }
itertools = { workspace = true }
lazy_static = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion git-branchless-lib/bin/testing/regression_test_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ fn assert_trees_equal(
let message = message.to_str_lossy();
let parents = current_commit.get_parents();
let actual_oid = repo.create_commit(
None,
&author,
&committer,
&message,
&actual_tree,
parents.iter().collect(),
None,
)?;
repo.find_commit_or_fail(actual_oid)?
};
Expand Down
57 changes: 57 additions & 0 deletions git-branchless-lib/src/core/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,16 @@ pub mod env_vars {
/// See <https://git-scm.com/docs/git#Documentation/git.txt---exec-pathltpathgt>.
pub const TEST_GIT_EXEC_PATH: &str = "TEST_GIT_EXEC_PATH";

/// Path to the `ssh-keygen` executable to use for signing functionality in
/// tests.
pub const TEST_SSH_KEYGEN: &str = "TEST_SSH_KEYGEN";

/// Path to the `gpg` executable to use for signing functionality in tests.
pub const TEST_GPG: &str = "TEST_GPG";

/// Path to the `gpgsm` executable to use for signing functionality in tests.
pub const TEST_GPGSM: &str = "TEST_GPGSM";

/// Specifies `git-branchless` subcommands to invoke directly.
///
/// For example, `TEST_SEPARATE_COMMAND_BINARIES=init test`, this function
Expand Down Expand Up @@ -381,6 +391,53 @@ or set `env.{0}` in your `config.toml` \
Ok(git_exec_path)
}

/// Get the path to the `ssh-keygen` executable for testing.
#[instrument]
pub fn get_path_to_ssh_keygen() -> eyre::Result<PathBuf> {
let path_to_ssh_keygen = std::env::var_os(TEST_SSH_KEYGEN).ok_or_else(|| {
eyre::eyre!(
"No path to `ssh-keygen` executable was set. \
Try running as: `{0}=$(which ssh-keygen) cargo test ...` \
or set `env.{0}` in your `config.toml` \
(see https://doc.rust-lang.org/cargo/reference/config.html)",
TEST_SSH_KEYGEN,
)
})?;
let path_to_ssh_keygen = PathBuf::from(&path_to_ssh_keygen);
Ok(path_to_ssh_keygen)
}

/// Get the path to the `gpg` executable for testing.
#[instrument]
pub fn get_path_to_gpg() -> eyre::Result<PathBuf> {
let path_to_gpg = std::env::var_os(TEST_GPG).ok_or_else(|| {
eyre::eyre!(
"No path to `gpg` executable was set. \
Try running as: `{0}=$(which gpg) cargo test ...` \
or set `env.{0}` in your `config.toml` \
(see https://doc.rust-lang.org/cargo/reference/config.html)",
TEST_GPG,
)
})?;
let path_to_gpg = PathBuf::from(&path_to_gpg);
Ok(path_to_gpg)
}
/// Get the path to the `gpgsm` executable for testing.
#[instrument]
pub fn get_path_to_gpgsm() -> eyre::Result<PathBuf> {
let path_to_gpgsm = std::env::var_os(TEST_GPGSM).ok_or_else(|| {
eyre::eyre!(
"No path to `gpgsm` executable was set. \
Try running as: `{0}=$(which gpgsm) cargo test ...` \
or set `env.{0}` in your `config.toml` \
(see https://doc.rust-lang.org/cargo/reference/config.html)",
TEST_GPGSM,
)
})?;
let path_to_gpgsm = PathBuf::from(&path_to_gpgsm);
Ok(path_to_gpgsm)
}

/// Determine whether the specified binary should be run separately. See
/// [`TEST_SEPARATE_COMMAND_BINARIES`] for more details.
#[instrument]
Expand Down
Loading
Loading