Skip to content

Commit 92bb588

Browse files
committed
Rename revision to rev
This affects both the command line option as well as the config file.
1 parent 140d171 commit 92bb588

6 files changed

Lines changed: 33 additions & 37 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ git = "https://github.com/sindresorhus/pure"
248248

249249
#### Specifying a branch, tag, or commit
250250

251-
All Git sources also allow setting of one of the `branch`, `tag` or `revision`
251+
All Git sources also allow setting of one of the `branch`, `tag` or `rev`
252252
fields. **sheldon** will then checkout the repository at this reference.
253253

254254
```toml

docs/plugins.example.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ prompt = { value = 'ln -sf "{{ filename }}" "{{ root }}/functions/prompt_{{ name
2222
[plugins.async]
2323
# `github` sources provide the repository in the form {username}/{repository}.
2424
github = "mafredri/zsh-async"
25-
# `github', `git`, or `gist` sources may provide a `branch`, `tag`, or
26-
# `revision` field.
25+
# `github', `git`, or `gist` sources may provide a `branch`, `tag`, or `rev`.
2726
tag = "v1.7.1"
2827
# All plugins can specify the template names that will be applied.
2928
apply = ["function"]

src/cli.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ struct Add {
7070
)]
7171
branch: Option<String>,
7272

73-
/// Checkout a specific revision.
73+
/// Checkout a specific commit.
7474
#[structopt(long, value_name = "SHA", group = "git-reference")]
75-
revision: Option<String>,
75+
rev: Option<String>,
7676

7777
/// Checkout a specific tag.
7878
#[structopt(long, value_name = "TAG", group = "git-reference")]
@@ -212,16 +212,16 @@ impl Plugin {
212212
local,
213213
protocol,
214214
branch,
215-
revision,
215+
rev,
216216
tag,
217217
directory,
218218
uses,
219219
apply,
220220
} = add;
221221

222-
let reference = match (branch, revision, tag) {
222+
let reference = match (branch, rev, tag) {
223223
(Some(s), None, None) => Some(GitReference::Branch(s)),
224-
(None, Some(s), None) => Some(GitReference::Revision(s)),
224+
(None, Some(s), None) => Some(GitReference::Rev(s)),
225225
(None, None, Some(s)) => Some(GitReference::Tag(s)),
226226
(None, None, None) => None,
227227
// this is unreachable because these three options are in the same mutually exclusive
@@ -522,7 +522,7 @@ OPTIONS:
522522
--local <DIR> Add a local directory
523523
--protocol <PROTO> The Git protocol for a Gist or GitHub plugin
524524
--branch <BRANCH> Checkout the tip of a branch
525-
--revision <SHA> Checkout a specific revision
525+
--rev <SHA> Checkout a specific commit
526526
--tag <TAG> Checkout a specific tag
527527
--directory <PATH> Which sub directory to use in this plugin
528528
--use <MATCH>... Which files to use in this plugin
@@ -556,7 +556,7 @@ ARGS:
556556
"test",
557557
"--git",
558558
"https://github.com/rossmacarthur/sheldon-test",
559-
"--revision",
559+
"--rev",
560560
"ad149784a1538291f2477fb774eeeed4f4d29e45",
561561
"--directory",
562562
"missing",
@@ -581,7 +581,7 @@ ARGS:
581581
local: None,
582582
protocol: None,
583583
branch: None,
584-
revision: Some("ad149784a1538291f2477fb774eeeed4f4d29e45".into()),
584+
rev: Some("ad149784a1538291f2477fb774eeeed4f4d29e45".into()),
585585
tag: None,
586586
directory: Some("missing".into()),
587587
uses: Some(vec_into!["{name}.sh", "*.zsh"]),
@@ -622,7 +622,7 @@ ARGS:
622622
local: None,
623623
protocol: Some("ssh".parse().unwrap()),
624624
branch: None,
625-
revision: None,
625+
rev: None,
626626
tag: Some("0.1.0".into()),
627627
directory: Some("missing".into()),
628628
uses: Some(vec_into!["{name}.sh", "*.zsh"]),
@@ -663,7 +663,7 @@ ARGS:
663663
local: None,
664664
protocol: Some("https".parse().unwrap()),
665665
branch: Some("feature".into()),
666-
revision: None,
666+
rev: None,
667667
tag: None,
668668
directory: Some("missing".into()),
669669
uses: Some(vec_into!["{name}.sh", "*.zsh"]),
@@ -698,7 +698,7 @@ ARGS:
698698
local: None,
699699
protocol: None,
700700
branch: None,
701-
revision: None,
701+
rev: None,
702702
tag: None,
703703
directory: None,
704704
uses: Some(vec_into!["{name}.sh", "*.zsh"]),
@@ -733,7 +733,7 @@ ARGS:
733733
local: Some("~/.dotfiles/zsh/pure".into()),
734734
protocol: None,
735735
branch: None,
736-
revision: None,
736+
rev: None,
737737
tag: None,
738738
directory: None,
739739
uses: Some(vec_into!["{name}.sh", "*.zsh"]),

src/config.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub enum GitReference {
5252
/// From the tip of a branch.
5353
Branch(String),
5454
/// From a specific revision.
55-
Revision(String),
55+
Rev(String),
5656
/// From a tag.
5757
Tag(String),
5858
}
@@ -584,8 +584,8 @@ impl RawPlugin {
584584
TempSource::External(source) => {
585585
if !source.is_git() && is_reference_some {
586586
bail!(
587-
"the `branch`, `tag`, and `revision` fields are not supported by this \
588-
plugin type"
587+
"the `branch`, `tag`, and `rev` fields are not supported by this plugin \
588+
type"
589589
);
590590
} else if protocol.is_some() && !is_gist_or_github {
591591
bail!("the `protocol` field is not supported by this plugin type");
@@ -604,10 +604,7 @@ impl RawPlugin {
604604
TempSource::Inline(raw) => {
605605
let unsupported = [
606606
("`protocol` field is", protocol.is_some()),
607-
(
608-
"`branch`, `tag`, and `revision` fields are",
609-
is_reference_some,
610-
),
607+
("`branch`, `tag`, and `rev` fields are", is_reference_some),
611608
("`directory` field is", directory.is_some()),
612609
("`use` field is", uses.is_some()),
613610
("`apply` field is", apply.is_some()),
@@ -786,9 +783,9 @@ mod tests {
786783
}
787784

788785
#[test]
789-
fn git_reference_deserialize_revision() {
790-
let test: TestGitReference = toml::from_str("revision = 'cd65e828'").unwrap();
791-
assert_eq!(test.g, GitReference::Revision(String::from("cd65e828")));
786+
fn git_reference_deserialize_rev() {
787+
let test: TestGitReference = toml::from_str("rev = 'cd65e828'").unwrap();
788+
assert_eq!(test.g, GitReference::Rev(String::from("cd65e828")));
792789
}
793790

794791
#[derive(Deserialize)]
@@ -1129,7 +1126,7 @@ mod tests {
11291126
.unwrap_err();
11301127
assert_eq!(
11311128
error.to_string(),
1132-
"the `branch`, `tag`, and `revision` fields are not supported by this plugin type"
1129+
"the `branch`, `tag`, and `rev` fields are not supported by this plugin type"
11331130
);
11341131
}
11351132

src/lock.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ pub struct LockedConfig {
124124
impl fmt::Display for GitReference {
125125
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
126126
match self {
127-
Self::Branch(s) | Self::Revision(s) | Self::Tag(s) => write!(f, "{}", s),
127+
Self::Branch(s) | Self::Rev(s) | Self::Tag(s) => write!(f, "{}", s),
128128
}
129129
}
130130
}
@@ -138,7 +138,7 @@ impl GitReference {
138138
fn lock(&self, repo: &git2::Repository) -> Result<LockedGitReference> {
139139
match self {
140140
Self::Branch(s) => git::resolve_branch(repo, s),
141-
Self::Revision(s) => git::resolve_revision(repo, s),
141+
Self::Rev(s) => git::resolve_rev(repo, s),
142142
Self::Tag(s) => git::resolve_tag(repo, s),
143143
}
144144
.map(LockedGitReference)
@@ -830,7 +830,7 @@ mod tests {
830830
"feature"
831831
);
832832
assert_eq!(
833-
GitReference::Revision("ad149784a".to_string()).to_string(),
833+
GitReference::Rev("ad149784a".to_string()).to_string(),
834834
"ad149784a"
835835
);
836836
assert_eq!(GitReference::Tag("0.2.3".to_string()).to_string(), "0.2.3");
@@ -854,18 +854,18 @@ mod tests {
854854
}
855855

856856
#[test]
857-
fn git_reference_lock_revision() {
857+
fn git_reference_lock_rev() {
858858
let temp = tempfile::tempdir().expect("create temporary directory");
859859
let repo = git_clone_sheldon_test(&temp);
860860

861-
let reference = GitReference::Revision("ad149784a".to_string());
861+
let reference = GitReference::Rev("ad149784a".to_string());
862862
let locked = reference.lock(&repo).unwrap();
863863
assert_eq!(
864864
locked.0.to_string(),
865865
"ad149784a1538291f2477fb774eeeed4f4d29e45"
866866
);
867867

868-
let reference = GitReference::Revision("2c4ed7710".to_string());
868+
let reference = GitReference::Rev("2c4ed7710".to_string());
869869
let error = reference.lock(&repo).unwrap_err();
870870
assert_eq!(error.to_string(), "failed to find revision `2c4ed7710`");
871871
}
@@ -963,7 +963,7 @@ mod tests {
963963
&create_test_context(directory),
964964
directory.to_path_buf(),
965965
Url::parse("https://github.com/rossmacarthur/sheldon-test").unwrap(),
966-
Some(GitReference::Revision(
966+
Some(GitReference::Rev(
967967
"ad149784a1538291f2477fb774eeeed4f4d29e45".to_string(),
968968
)),
969969
)
@@ -988,7 +988,7 @@ mod tests {
988988
&create_test_context(directory),
989989
directory.to_path_buf(),
990990
Url::parse("git://github.com/rossmacarthur/sheldon-test").unwrap(),
991-
Some(GitReference::Revision(
991+
Some(GitReference::Rev(
992992
"ad149784a1538291f2477fb774eeeed4f4d29e45".to_string(),
993993
)),
994994
)

src/util.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,10 @@ pub mod git {
223223
}
224224

225225
/// Resolve a revision to a object identifier.
226-
pub fn resolve_revision(repo: &Repository, revision: &str) -> anyhow::Result<Oid> {
226+
pub fn resolve_rev(repo: &Repository, rev: &str) -> anyhow::Result<Oid> {
227227
let obj = repo
228-
.revparse_single(revision)
229-
.with_context(s!("failed to find revision `{}`", revision))?;
228+
.revparse_single(rev)
229+
.with_context(s!("failed to find revision `{}`", rev))?;
230230
Ok(match obj.as_tag() {
231231
Some(tag) => tag.target_id(),
232232
None => obj.id(),

0 commit comments

Comments
 (0)