Git Product home page Git Product logo

zbg's People

Contributors

chshersh avatar etorreborre avatar kephas avatar leedsjohn avatar paulpatault avatar sloboegen avatar tekknoid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

zbg's Issues

New command 'zbg done'

This command should:

  1. Run zbg switch with the default arguments.
  2. Delete the previous branch locally if it's not the branch we're switching from.

zbg commit bad practice

zbg commit ran a git add ..

This isn't really considered good practice because there can be temp, test or unfinshed files that need to manually be unstaged which can be quite tedious.

Solution: Implement a separate zbg add <files> command, allowing the commit command to function as just that.

Idea: `zbg undo`

I think I don't need it anymore, but when anyone starts using git, a thing that we would really want is a Ctrl+Z, haha 😁

So the idea would be to have a zbg undo command that looks at the current state of git and aborts it when it's supported, or undoes the commit otherwise.

  • If in rebase, it would do git rebase --abort (grba)
  • If in merge, it would do git merge --abort (gma)
  • If in cherry-pick, it would do git cherry-pick --abort
  • ...insert every command that supports --abort
  • The fallback could be to undo the latest commit: git reset --soft HEAD~1

Global `.gitignore`

Seems like zbg do not take in account by global .gitignore file

.DS_Store
.vscode/
*.code-workspace

Take a look

❯ zbg status    
 added  .DS_Store                                   | Bin 0 -> 6148 bytes
 added  .github/.DS_Store                           | Bin 0 -> 6148 bytes
 added  .vscode/settings.json                       |   6 ■■■■■■
 added  .vscode/tasks.json                          |  50 ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
 added  other/.DS_Store                             | Bin 0 -> 6148 bytes
 added  other/join-service/.vscode/settings.json    |   6 ■■■■■■
 added  src/.DS_Store                               | Bin 0 -> 6148 bytes
 added  src/Context/.DS_Store                       | Bin 0 -> 6148 bytes
 added  src/Context/Individual/.DS_Store            | Bin 0 -> 6148 bytes
 added  src/Context/Individual/Connection/.DS_Store | Bin 0 -> 6148 bytes
 added  src/Context/Individual/Domain/.DS_Store     | Bin 0 -> 6148 bytes
 added  src/Core/.DS_Store                          | Bin 0 -> 6148 bytes
 added  tests/.DS_Store                             | Bin 0 -> 6148 bytes
 added  union-server.code-workspace                 |  39 ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■

and

union-server on  master via 🐳 desktop-linux via λ lts-20.26 
❯ git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

New Command: `zbg amend`

I'm wondering if this would be worth adding. I know that I tend to use git commit --amend a lot when working on projects if my commits tend to be related somehow before pushing to some remote branch. This is somewhat destructive because it changes the previous commit but in that case we could just hide it behind a prompt if we're worried about that.

Format the commit message

One thing that I miss with zbg is a way to format the commit message like with the cmt Haskell tool.

zbg new already goes in the direction of having some convention for branch names (with the user.login prefix), I think it would be good to go one step further with commit messages. This could be totally optional:

  • If a .cmt file is defined locally, use that file as a template for the commit message (see the cmt demo)
  • If there is no .cmt file then let the user type a regular commit message.

Escape messages in 'zbg stash'

Currently, messages for the zbg stash command are not escaped. This can result in weird behaviour.

zbg/lib/git.ml

Line 125 in 42bdb5c

Printf.sprintf "--message='%s'" msg (* TODO: proper escaping *)

Probably, the quote_command function from Unix should be used.

  • Escape the message argument
  • Write tests

New command: 'zbg clone'

A new command zbg clone to type the owner and repository name easier.

$ zbg clone tool-sync
🐚  git clone [email protected]:chshersh/tool-sync.git

$ zbg clone BurntSushi/ripgrep
🐚  git clone [email protected]:BurntSushi/ripgrep.git

Behaviour:

  • By default, clones your personal repository when the owner name is omittied
  • Otherwise, clones the full repository name

Support both -f and --force flags

Currently, zbg supports only the -f flag for forceful actions:

zbg/lib/cli.ml

Line 17 in 7b44863

flag "f" no_arg ~doc:"Clear forcefully without asking any questions"

However, it would be nice to support --force as well. Unfortunately, it looks like Core.Command doesn't support specifying multiple aliases for the same flag (or maybe I just haven't found it). But it would be nice to have it! (ideally, without rewriting the CLI parser to a different library).

https://ocaml.org/p/core/v0.12.3/doc/Core/Command/Param/index.html

Use pure function instead of calling 'basename'

Currently, zbg calls a separate process basename to extract the branch name.

zbg/lib/git.ml

Lines 13 to 14 in 7b44863

Process.proc_stdout @@ Printf.sprintf "basename %s" remote_main_branch
(* TODO: use pure function *)

However, this is unnecessary as it could be implemented as a pure function (maybe a filepath library already has it?).

The plan:

  • Move stripping via basename into a separate function
  • Write tests to handle various cases
  • Replace with the pure function

Write tests for 'zbg commit'

To make sure that escaping works as expected

zbg/lib/git.ml

Lines 66 to 71 in b9be80f

let commit message_words =
let message = Extended_string.unwords message_words in
Process.proc "git add .";
match message with
| "" -> Process.proc "git commit"
| message -> Process.proc @@ Printf.sprintf "git commit --message=%S" message

Colour staged files in 'zbg status'

Currently, zbg doesn't highlight already staged files in any way like git status does. I think it would be a good idea.

Maybe highlight file names as bold green if the file was staged?

git

image

zbg

image

status can't print diff when different path than root

Hi @chshersh, really good tool. Thanks for the effort and style on zbg.

I'm using it and found a bug when running status from a different path than root (containing the .git folder)

→ $ zbg status
 modified  .gitignore                         |   1 ■
 modified  dune                               |   2 ■■
 modified  dune-project                       |   2 ■■
 modified  e2e/rescript-v9-JSX3/bsconfig.json |   3 ■■■
 modified  e2e/rescript-v9-JSX3/package.json  |   3 ■■■
 modified  e2e/rescript-v9-JSX3/yarn.lock     | Bin 87888 -> 64994 bytes
 added     packages/css/bsconfig.json         |   8 ■■■■■■■■

→ $ cd bin

→ $ zbg status
 modified  .gitignore                         | 0 <unable to match file>
 modified  dune                               | 0 <unable to match file>
 modified  dune-project                       | 0 <unable to match file>
 modified  e2e/rescript-v9-JSX3/bsconfig.json | 0 <unable to match file>
 modified  e2e/rescript-v9-JSX3/package.json  | 0 <unable to match file>
 modified  e2e/rescript-v9-JSX3/yarn.lock     | 0 <unable to match file>

Implement the --dry-run flag

So users could see git commands before actually running them.

This would probably require rewriting the whole project.

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.