Skip to content

Commit 8b92cb6

Browse files
authored
Merge pull request #22 from KnpLabs/v0.2.0
v0.2.0
2 parents 213de18 + c7852de commit 8b92cb6

File tree

16 files changed

+156
-28
lines changed

16 files changed

+156
-28
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
ci/Cargo.lock
33
cli/Cargo.lock
44
git/Cargo.lock
5+
logger/Cargo.lock
56
utils/Cargo.lock
67
target/

Cargo.lock

Lines changed: 42 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ssc"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
description = "A CLI tool to skip a CI build that is not concerned by the latest changes."
55
homepage = "https://github.com/KnpLabs/should-skip-ci"
66
repository = "git@github.com:KnpLabs/should-skip-ci.git"
@@ -15,6 +15,7 @@ edition = "2018"
1515
ci = { path = "ci" }
1616
cli = { path = "cli" }
1717
git = { path = "git" }
18+
logger = { path= "logger" }
1819

1920
[dev-dependencies]
2021
rand = "0.7"

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ $ sudo curl -sSL -o /usr/local/bin/ssc https://github.com/KnpLabs/should-skip-ci
6262
$ sudo chmod +x /usr/local/bin/ssc
6363
```
6464

65+
See the latest version in the [releases panel](https://github.com/KnpLabs/should-skip-ci/releases).
66+
6567
### Usage
6668

6769
```
@@ -71,6 +73,7 @@ USAGE:
7173
FLAGS:
7274
-h, --help Prints help information
7375
-V, --version Prints version information
76+
-v,-vv Increases verbosity (-v for info, -vv for debug).
7477
7578
OPTIONS:
7679
--base-branch <base-branch> The branch to use as a base to know from where the commit range starts (i.e. to

ci/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
[package]
22
name = "ci"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
authors = ["KNP Labs"]
55
edition = "2018"
6+
7+
[dependencies]
8+
log = "0.4.8"

ci/src/lib.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
1+
extern crate log;
2+
13
use std::process::Command;
4+
use log::debug;
25

36
pub fn run_stop_cmd(cmd: &String) -> i32 {
47
// As the cmd to run is a single string, we run it though a shell
58
// otherwise rust will look for an executable which *is* the whole
69
// `cmd` string.
7-
let result = Command::new("/bin/sh")
10+
let mut command = Command::new("/bin/sh");
11+
command
812
.arg("-c")
913
.arg(cmd)
14+
;
15+
16+
debug!("Running `{:?}`", command);
17+
18+
let result = command
1019
.output()
1120
.expect("Unable to run the stop command.")
1221
;
1322

23+
1424
return result.status.code().unwrap();
1525
}
1626

cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cli"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
authors = ["KNP Labs"]
55
edition = "2018"
66

cli/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ struct RawCli {
1717

1818
#[structopt(long = "cmd", help = "The command to use to skip the build.")]
1919
cmd: String,
20+
21+
// The number of occurrences of the `v/verbose` flag
22+
/// Verbose mode (-v, -vv, -vvv, etc.)
23+
#[structopt(short, long, parse(from_occurrences), help = "Verbosity mode : -v, -vv")]
24+
verbosity: u8,
2025
}
2126

2227
// The Cli struct represents the resolved CLI args and options.
@@ -57,4 +62,8 @@ impl Cli {
5762
pub fn cmd(&self) -> &String {
5863
return &self.raw_cli.cmd;
5964
}
65+
66+
pub fn verbosity(&self) -> &u8 {
67+
return &self.raw_cli.verbosity;
68+
}
6069
}

git/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
[package]
22
name = "git"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
authors = ["KNP Labs"]
55
edition = "2018"
66

77
[dependencies]
88
utils = { path = "../utils" }
9+
log = "0.4.8"

git/src/branch.rs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
1+
extern crate log;
2+
13
use std::path::PathBuf;
24
use std::process::Command;
5+
use log::debug;
36

47
use utils::assert_or_panic;
58

69
pub fn get_current_branch(
710
working_directory: &PathBuf,
811
) -> String {
9-
let result = Command::new("git")
12+
let mut cmd = Command::new("git");
13+
cmd
1014
.arg("rev-parse")
1115
.arg("--abbrev-ref")
1216
.arg("HEAD")
1317
.current_dir(&working_directory)
18+
;
19+
20+
debug!("Running `{:?}`", cmd);
21+
22+
let result = cmd
1423
.output()
1524
.expect("Failed to determine current branch.")
1625
;
@@ -25,10 +34,16 @@ pub fn get_current_branch(
2534
pub fn get_current_remote(
2635
working_directory: &PathBuf,
2736
) -> String {
28-
let result = Command::new("git")
37+
let mut cmd = Command::new("git");
38+
cmd
2939
.arg("remote")
3040
.arg("show")
3141
.current_dir(&working_directory)
42+
;
43+
44+
debug!("Running `{:?}`", cmd);
45+
46+
let result = cmd
3247
.output()
3348
.expect("Failed to determine current remote.")
3449
;
@@ -45,7 +60,8 @@ pub fn get_merge_base_commit(
4560
remote: &String,
4661
base_branch: &String,
4762
) -> String {
48-
let result = Command::new("git")
63+
let mut cmd = Command::new("git");
64+
cmd
4965
.arg("merge-base")
5066
.arg(format!(
5167
"{}/{}",
@@ -54,6 +70,11 @@ pub fn get_merge_base_commit(
5470
))
5571
.arg("HEAD")
5672
.current_dir(&working_directory)
73+
;
74+
75+
debug!("Running `{:?}`", cmd);
76+
77+
let result = cmd
5778
.output()
5879
.expect("Failed to determine merge base.")
5980
;

0 commit comments

Comments
 (0)