Skip to content
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

Proposal for unit & integration testing #1

Merged
merged 24 commits into from
Oct 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
76b5fd0
Draft: proposal for unit & integration testing
robertdfrench Oct 10, 2021
e187ac1
Fixes #3: Rewrite fake_git in Rust
Oct 10, 2021
956844e
Move `with_path` impl to tests module. Fixes #4.
robertdfrench Oct 10, 2021
52c2d23
Test for remote refs which don't fit PR pattern.
robertdfrench Oct 10, 2021
234cec3
Add bare-minimum documentation
robertdfrench Oct 10, 2021
5f90c9f
Custom error type for git invocations. Fixes #5.
robertdfrench Oct 11, 2021
70661fd
Comment out Cargo.lock in gitignore. Fixes #12.
Oct 11, 2021
625c00d
Simplify pattern matching in fake_git. Fixes #13.
Oct 11, 2021
7e42b1f
Replace OsString/Path with String. Fixes #11.
Oct 11, 2021
f5e9c5d
Give rough overview in README
robertdfrench Oct 12, 2021
a436994
Better example formatting. Fixes #14
robertdfrench Oct 12, 2021
c0a8dae
Match anything but '/' for origin name. Fixes #6.
robertdfrench Oct 13, 2021
fc69b49
Resolve a line-ordering conflict in README.md
robertdfrench Oct 13, 2021
12704d2
Test in release mode!
robertdfrench Oct 13, 2021
985096a
Add more prints in GitHub YAML for debugging
Oct 13, 2021
aa25626
More debugging for PR failure
Oct 13, 2021
9943f2b
Add setup repo step in GH actions yml. Fixes #17
Oct 13, 2021
0025909
Add setup repo step in GH actions yml. Fixes #17
Oct 13, 2021
022dc6d
Add setup repo step in GH actions yml. Fixes #17
Oct 13, 2021
f0513fc
Print statment to help debug this more...
Oct 13, 2021
ce0145f
Undo debugging for now...
Oct 13, 2021
7efa1ba
Create working git repo for integration tests
robertdfrench Oct 13, 2021
1756869
Include tempdir crate
robertdfrench Oct 13, 2021
748b183
Setup git config name and email
robertdfrench Oct 13, 2021
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
9 changes: 5 additions & 4 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: CheckoutRepo
uses: actions/checkout@v2
- name: Build
run: cargo build --release --verbose
- name: Run tests
run: cargo test --release --verbose
run: cargo build --release
- name: Test
run: RUST_BACKTRACE=1 cargo test --release
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock
#Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk
Expand Down
140 changes: 140 additions & 0 deletions Cargo.lock

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

29 changes: 5 additions & 24 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,12 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
regex = "1"
lazy_static = "1.4.0"

[dev-dependencies]
tempdir = "0.3.7"

[lib]
name = "libgitpr"
path = "src/lib.rs"

[[bin]]
name = "git-pr-list"
path = "src/list.rs"

[[bin]]
name = "git-pr-clean"
path = "src/clean.rs"

[[bin]]
name = "git-pr-accept"
path = "src/accept.rs"

[[bin]]
name = "git-pr-create"
path = "src/create.rs"

[[bin]]
name = "git-pr-rebase"
path = "src/rebase.rs"

[[bin]]
name = "git-pr-abandon"
path = "src/abandon.rs"
44 changes: 42 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,43 @@
![build status](https://github.com/robertdfrench/git-pr/actions/workflows/rust.yml/badge.svg)
# git-pr
Pull requests without Git(Hub|Lab)
# `git-pr`
*Pull requests without Git{Hub,Lab,Whatever}*

[License](https://github.com/robertdfrench/portunusd/blob/trunk/LICENSE)
❘
[Roadmap](https://github.com/robertdfrench/git-pr/milestones)
❘
[Download](https://github.com/robertdfrench/git-pr/releases)

Git does not support pull requests by default, but it could! By following a few
simple conventions, any shared repository can support pull requests without
additional tooling required from the host. `git-pr` is tooling to implement
those conventions, making it easy to create, approve, or destroy pull requests
-- all from the command line:

```console
$ git pr-create hotfix # Create a new branch for an emergency hotfix
Switched to a new branch 'hotfix/0'
...
* [new branch] hotfix/0 -> hotfix/0
Branch 'hotfix/0' set up to track remote branch 'hotfix/0' from 'origin'.
$ # (code code code...)
$ git push # Submit for review... it's just a branch!
```

Meanwhile, your collaborators can check for the latest updates, review your
changes, and even merge them:

```console
$ git pr-list # Check the server for new PRs
...
* [new branch] hotfix/0 -> hotfix/0
hotfix
remove-hardcoded-passwords
use-git-pr-tool
$ # (review review review...)
$ git pr-accept hotfix # LGTM!
```

Given this minimalist approach, the means of communication is up to you. We
don't try to force you into some mechanism that just ends up emailing you
anyway. :smirk:
8 changes: 8 additions & 0 deletions src/bin/failing_git.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//! A program that always returns an error.
//!
//! Used to facilitate testing scenarios where git should immediately fail.
use std::process::exit;

fn main() {
exit(1)
}
18 changes: 18 additions & 0 deletions src/bin/fake_git.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//! A mock implementation of git.
//!
//! Used to facilitate testing scenarios where prescribed behavior is required, and would be too
//! cumbersome to obtain from "real git". Should only be used in unit testing; integration tests
//! should still run against an actual git binary.
use std::env;
use std::process::exit;

fn main() {
let first_arg = env::args().nth(1);
match first_arg.as_deref() {
None => exit(1),
Some("--version") => println!("fake_git version 1"),
Some(_) => exit(1)
};

exit(0);
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
15 changes: 15 additions & 0 deletions src/bin/git-pr-list.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//! Display a list of currently active Pull Requests
//!
//! By "currently active", we mean "not yet deleted from the remote".
use libgitpr;

fn main() -> Result<(),libgitpr::GitError> {
let git = libgitpr::Git::new();
git.fetch_prune()?;
let branches = git.all_branches()?;

for pr_name in libgitpr::extract_pr_names(&branches) {
println!("{}", pr_name);
}
Ok(())
}
File renamed without changes.
Loading