Giter VIP home page Giter VIP logo

git-pr's Introduction

build status

git-pr

Pull requests without Git{Hub,Lab,Whatever}

License โ˜ Roadmap โ˜ Download

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:

$ 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:

$ 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. ๐Ÿ˜

git-pr's People

Contributors

robertdfrench avatar

Watchers

 avatar James Cloos avatar  avatar

Forkers

calebwherry

git-pr's Issues

git-pr-create fails to retry after network error

  1. Disconnect network
  2. git-pr-create A creates a local, but not a remote branch
  3. Connect network
  4. git-pr-create A exits nonzero after detecting that the local branch A/123abc already exists, and does not re-attempt to create the remote branch

Use the type system to distinguish output from git

We have a lot of functions that accept strings as input, but they expect those strings to have certain internal structure. We could take advantage of the type system, and return/accept something like:

struct GitBranchDashA {
    content: String
}

Inject `Command`-like object into Git client

This will let Git client prepare the argument string for git, and this argument string can be unit-tested in memory. Separately, the Command-like type can be integration tested against a much smaller example binary.

Each tagged commit in trunk should result in a GitHub release

This might require a separate pipeline. The idea is that, while everything in trunk should always be in "release-ready" state, we might not want to release every single merge. Pushing tags to trunk gives us the opportunity to define a separate GitHub Action with permission to post its built artifacts to the GitHub API in order to create a release.

Write GIT-PR(1) man page

When installed, git subcommands each come with their own unix manual entries:

plus a high-level entry to document the whole subsystem:

We should at least write the high-level man page, and if we can stomach roff, go back and write individual pages for each command in our suite.

Create macro for TestState

Currently, we "touch" the global test state by just printing the state:

println!("TempDir='{:?}'", TEST_STATE.path());

But we should really push this into a macro and call it "init_test_state" or something.

How will we handle installation?

Between the git-pr binaries and their associated documentation (#29) we are looking at distributing about a dozen artifacts to end users. What options do we have for installation?

1. Let Cargo Do it

The easiest path may be to distribute via crates.io. While intended for libraries, some binaries are distributed this way, though mostly only stuff intended as Rust development tools (clippy, et al). That might look like this:

$ cargo install git-pr
...downloading...
...compiling...
...installing???

I don't know for sure if cargo supports installing things in system-wide paths, or if it will only install them within the user's home directory. git is smart enough to find the binaries as long as they are in $PATH, but man won't be able to find the documentation unless its in $MANPATH, which users are much less likely to want to customize.

2. Write some bogus script

If we'll always be targeting a bash-capable environment (thinking of GitBash for Windows here), then we could:

  1. Find the right analogue of /usr/local/libexec/git, and try to put the binaries there
  2. Find an appropriate spot on the filesystem to stick the man pages
  3. Figure out what GitBash's interpretation of "sudo" would be on Windows

3. Integrate with package managers

This would be by far the most work, but probably also the best solution for users.

  • Chocolatey for Windows
  • PkgSrc or Homebrew for macOS
  • Apt for Debian / Ubuntu

Harden GitHub settings

Some things I think we should do:

  • Only allow trunk commits via PR
  • Setup security policies
  • Add aux files to repo like CONTRIB or other files that GH can use

Probably many more but definitely wanted to get the first 2 done.

What is the value of `fake_git`?

At the moment, the tests that depend on fake_git are more-or-less ask the question "have we invoked git with the right arguments?". I am not sure what we get from this.

I think it made sense initially to have fake_git and failing_git so that we could test our strategy for executing subprocesses. I am less sure that it makes sense to keep extending fake_git with new subcommands, only to turn around and write a similar integration test against real git.

Enhance Readme

Needs things like:

  • General info
  • Build/release badges
  • Platform support

Implement git-pr-rebase command

Create a new branch by rebasing against the latest trunk, using trunks hash as the "revision" of the PR. Remove all previous revisions of the PR.

Implement git-pr-accept command

Merge the branch into trunk iff the branch can be fast-forwarded (that is, the branch must contain a descendant of trunk). The branch will then be discarded both locally and on the origin remote.

Investigate simplifying fake_git pattern matching

With the fake git mocks, we want simple binaries with the least number of dependencies. So, for CLI options that are dead simple, we don't want to use CLAP (like we do in the actual product binaries). We ran into an issue with matching on Option that required some ugly looking code:

     let first_arg = env::args().nth(1);
     match first_arg {
         None => exit(1),
         Some(val) => {
             if val == "--version" {
                 println!("fake_git version 1");
             } else {
                 exit(1);
             }
         }
     };

For some reason, we could not match using something like Some("--version"). Should be doable and much cleaner to do it this... but how?

Write a tutorial!

We are doing a moderately good job documenting the code, and we have plans (#29) to write reference documentation for each individual command, but nothing beats a good overall tutorial with usage examples.

Tab Completion Modules?

How does tab completion work, and can we support it? RipGrep uses clap to automatically generate tab completion files for some shells:

    // Use clap to build completion files.
    let mut app = app::app();
    app.gen_completions("rg", Shell::Bash, &outdir);
    app.gen_completions("rg", Shell::Fish, &outdir);
    app.gen_completions("rg", Shell::PowerShell, &outdir);
    // Note that we do not use clap's support for zsh. Instead, zsh completions
    // are manually maintained in `complete/_rg`.

Zsh-specific

git-pr-list only shows branches ending in digits

This bug is sortof speculating that we will eventually accept #24 in something close to its current form; if so, then git-pr-list will want to be aware of branches ending in hexadecimal numbers, rather than just digits:

static ref ENDS_WITH_DIGIT: Regex = Regex::new(r"/\d+$").unwrap();

Prefer String over Path/OsString

We don't need Path anymore, because @calebwherry found that we don't need the Path construction stuff that I assumed we needed on Windows. I also didn't realize that String implements a trait called AsRef<OsStr>, meaning that it can be passed as a reference to std::process::Command::new. So that will bring the number of string types in this code from 3 down to 1!

Originally posted by @robertdfrench in #1 (comment)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.