Coder Social home page Coder Social logo

git-rex's People

Contributors

alicederyn avatar

Watchers

 avatar  avatar

git-rex's Issues

Support multiple shells

In particular, the following shells are likely to be desireable to anyone not familiar with bash:

  • ksh
  • tcsh
  • python

This issue should be split into multiple issues, one per shell, prior to implementation.

Add --from-history flag

It would be very convenient for rex to offer a --from-history flag, where it captures all the current shell's history, back to whatever the last git command was, and drop into an editor for a commit message with said commands listed in a script block.

This feature is likely to have a lot of subtle complexities to worry about; for instance, certain git commands like diff are a common part of establishing that a command has done what the user anticipated, so should be skipped over in the history.

Should respect the core.editor config, if set.

Cannot run with python 3.8

Error trace from version 0.2.0:

$ git rex -h
Traceback (most recent call last):
  File "/home/apurcell14/.local/bin/git-rex", line 5, in <module>
    from git_rex import main
  File "/home/apurcell14/.local/pipx/venvs/git-rex/lib/python3.8/site-packages/git_rex/__init__.py", line 33, in <module>
    def extract_script(message: str) -> tuple[str, ...]:
TypeError: 'type' object is not subscriptable

I note that the CI tests for python 3.8 just say "Error" on the step that should install this version of python, which is probably why we have regressed.

Add --edit flag

The following should be valid commands:

  • git rex --edit COMMIT โ€” Opens the commit message of COMMIT in an editor prior to executing the script, similar to git cherry-pick --edit
  • git rex --edit โ€” Opens a template commit message in an editor; executes the user-supplied script and commits.

Both will need to implement the behaviour of the git commit --cleanup flag prior to executing the script. Optionally, we could add a new default mode that does not ignore comments in script sections, as that's probably going to be pretty convenient.

Automated commit created with git-rex

The following commands were executed:

```bash
# Enter your script here. It will be executed, and all files created
# or changed committed to your repository.
```

# Please enter the commit message for your changes. Lines starting
# with '#', except those in script sections, will be ignored, and an
# empty commit message, or one with no script commands to execute,
# aborts the commit.
#
# On branch foo

Both should respect the core.editor config, if set.

Script blocks should run in a single shell

The following:

mkdir foo
cd foo
echo "Hello there" > bar.txt

should create bar.txt in the folder foo/, but currently does not.

Separate script blocks should be run in separate shells (in particular, doing a cd in one script block should not affect any subsequent script block).

Errors should be handled as if -e and -o pipefail were set

Add --verbose flag

This should probably do at least the following:

  • Run set -x in bash
  • Message when each bash script finishes, and with what status code Not necessary now we have fixed #27

Comments in script sections not ignored

Currently, git rex relies on comments being stripped from commit messages. However, depending on the value of the git commit --cleanup flag, comments may be left in. rex should strip them (and, in particular, error if a commit contains only comments in its script section).

No manual entry

$ git rex --help
No manual entry for git-rex

We might be able to leverage argparse-manpage to do the actual generation. However, I am unclear:

  • how to run the generator automatically with poetry
  • where the manpage needs to live for git to pick it up
  • how one would then get it there with pipx

Add --no-commit flag

This should function like cherry-pick --no-commit:

  • leaves changes uncommitted
  • disables the startup check that the index is clean
  • leaves the commit message in .git/MERGE_MSG

Ideally, it would also flatten the executed script in interactive mode, though that introduces a lot of complexities around state (e.g. cwd, env vars).

Add --interactive flag

It would be very convenient for rex to offer an --interactive mode, where it enters a REPL for bash that captures all commands run and, once the user has run exit or hit ^D, drops into an editor for a commit message with all evaluated commands listed in a script block.

We can probably leverage bash itself for the REPL, if we can reliably configure its history mode without the user's config files interfering. This means:

  • Changing which file history gets written to
  • Turning off the leading-space-disables-history feature
  • Setting a trap for errors that documents ways to recover (e.g. using || true)

We will also ideally have some consistent way of handling executed git commands in a non-surprising way; for instance, we could do one or more of:

  • strip informational commands like status from the history
  • replace the command itself to intercept and disable commands like commit
  • leave the repository locked to prevent concurrent operations

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.