Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- (#1464): created `git split` command to extract changes from a commit
- (#1603): added `git move --dry-run` to test in-memory rebases
- (#1604): `git record` and `git amend` can now automatically detect and begin tracking new files (optional, disabled by default)
- (#1612): added `git record --new` to create new, empty commits
- (#1632): added `git record --fixup` option, to create a fixup commit (similar to `reword --fixup`)

### Changed
Expand Down
4 changes: 2 additions & 2 deletions git-branchless-lib/src/git/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ pub use reference::{
};
pub use repo::{
AmendFastOptions, CherryPickFastOptions, CreateCommitFastError, Error as RepoError,
GitErrorCode, GitVersion, PatchId, Repo, ResolvedReferenceInfo, Result as RepoResult, Time,
message_prettify,
GitErrorCode, GitVersion, PatchId, Repo, ResolvedReferenceInfo, Result as RepoResult,
Signature, Time, message_prettify,
};
pub use run::{GitRunInfo, GitRunOpts, GitRunResult};
pub use snapshot::{WorkingCopyChangesType, WorkingCopySnapshot};
Expand Down
14 changes: 14 additions & 0 deletions git-branchless-lib/src/git/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1659,6 +1659,18 @@ impl std::fmt::Debug for Signature<'_> {
}

impl<'repo> Signature<'repo> {
/// Create a new signature.
#[instrument]
pub fn new(name: &str, email: &str, now: &SystemTime) -> Result<Self> {
Ok({
Signature {
inner: git2::Signature::now(name, email).map_err(Error::CreateSignature)?,
}
.update_timestamp(*now)?
})
}

/// Create an automated signature, for internal use.
#[instrument]
pub fn automated() -> Result<Self> {
Ok(Signature {
Expand Down Expand Up @@ -1708,10 +1720,12 @@ impl<'repo> Signature<'repo> {
}
}

/// Get the name applied to this signature.
pub fn get_name(&self) -> Option<&str> {
self.inner.name()
}

/// Get the email applied to this signature.
pub fn get_email(&self) -> Option<&str> {
self.inner.email()
}
Expand Down
4 changes: 4 additions & 0 deletions git-branchless-opts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,10 @@ pub struct RecordArgs {
#[clap(action, short = 's', long = "stash", conflicts_with_all(&["create", "detach"]))]
pub stash: bool,

/// Create an empty commit, leaving any changes uncommitted.
#[clap(action, long = "new", conflicts_with("stash"))]
pub new: bool,

/// How should newly encountered, untracked files be handled?
#[clap(value_parser, long = "untracked", conflicts_with_all(&["interactive"]))]
pub untracked_file_strategy: Option<UntrackedFileStrategy>,
Expand Down
Loading
Loading