Skip to content

Throw an error if there are no staged files #7

Closed

Description

@kentcdodds

There's no reason to fill out the prompts if there are no staged files. You can determine this with:

git diff --cached

:-)

Activity

  1. jimthedev commented on Aug 7, 2015

    @jimthedev
    Member

    Great idea. Seems like a no brainier.

  2. kentcdodds commented on Aug 26, 2015

    @kentcdodds
    MemberAuthor

    What needs to happen for this to be implemented? This catches me up pretty much every single time and I also have githooks that take my commits about 15 seconds to go through so I don't realize my mistake until after that's done :-( This would be really helpful.

  3. jimthedev commented on Aug 30, 2015

    @jimthedev
    Member

    Up until now, I've created any of the features I needed in gulp-git. It is a project that is built for gulp, but we use it specifically for the library modules. I'd love to see Steve break that out into an actual library but it suits our needs but that's a separate conversation.

    Currently it does not have a git diff module. Initially we'd need to create a module for that command and get it merged into Steve's project. He is very responsive and requires tests for all changes.

    Alternatively, we could consider switching the git library that we use. I know this one exists:
    https://github.com/steveukx/git-js

    It has a diff module that we could try to use for this feature. If it works well then we could migrate the other git commands we use. Bottom line, we either need to add a dependency or get some changes merged into gulp-git and then implement them here.

  4. added this to the 2.0.0 milestone on Oct 13, 2015
  5. sebastienbarre commented on Oct 13, 2015

    @sebastienbarre

    OK, my gut feeling is that gulp-git is the more stable/popular of the two. I inquired in stephenlacy/gulp-git#97.

  6. jimthedev commented on Oct 13, 2015

    @jimthedev
    Member

    Thanks!!! I've also started just writing my own wrappers and parsers for v2
    so that might be an option for diff. It should pretty much be a regex
    On Tue, Oct 13, 2015 at 9:22 AM Sébastien Barré notifications@github.com
    wrote:

    OK, my gut feeling is that gulp-git is the more stable/popular of the
    two. I inquired in stephenlacy/gulp-git#97
    stephenlacy/gulp-git#97.

    —
    Reply to this email directly or view it on GitHub
    #7 (comment).

  7. sebastienbarre commented on Oct 13, 2015

    @sebastienbarre

    Hold on, can't this problem be solved already with gulp-git?

    • use git.status, then just grep to see if "Changes to be committed" is not there,
    • or use git.exec, and execute diff --cached from there? (aka git.exec({args : 'diff --cached'}, function (err, stdout) { ... });)
  8. jimthedev commented on Oct 13, 2015

    @jimthedev
    Member

    Yes! One question. Does git use different languages? If so then that grep
    might not work.
    On Tue, Oct 13, 2015 at 9:39 AM Sébastien Barré notifications@github.com
    wrote:

    Hold on, can't this problem be solved already with gulp-git?

    —
    Reply to this email directly or view it on GitHub
    #7 (comment).

  9. sebastienbarre commented on Oct 13, 2015

    @sebastienbarre

    Could be localized, you are correct. Option #2 then, because that would
    return an empty string if nothing is staged.

    On 10/13/15 10:41 AM, Jim Cummins wrote:

    Yes! One question. Does git use different languages? If so then that grep
    might not work.
    On Tue, Oct 13, 2015 at 9:39 AM Sébastien Barré notifications@github.com
    wrote:

    Hold on, can't this problem be solved already with gulp-git?

    —
    Reply to this email directly or view it on GitHub
    #7 (comment).

    —
    Reply to this email directly or view it on GitHub
    #7 (comment).

  10. jimthedev commented on Oct 13, 2015

    @jimthedev
    Member

    Ok, I'll make sure to write a test for this in what I currently calling v2.

    Side note: At the moment, I think v2 might actually be able to remain on the 1.x branch because as it is written, there should be no adapter breaking changes. The only thing that might make it called 2.x are some small cli changes. TBD.

  11. self-assigned this
    on Oct 13, 2015
  12. 8 remaining items

  13. jimthedev commented on Oct 15, 2015

    @jimthedev
    Member

    Cool. That's fair. I don't want to take away that functionality so I'll take a second look and try to get that working in the parser.

  14. kentcdodds commented on Oct 15, 2015

    @kentcdodds
    MemberAuthor

    I use git commit -am 'message' on a regular basis. But when I use
    commitizen, I first git add . and then run npm run commit which runs an
    npm script to run git-cz because I prefer to use the locally installed
    binary. So it doesn't make much of a difference for me.

    On Thu, Oct 15, 2015 at 11:41 AM Jim Cummins notifications@github.com
    wrote:

    Cool. That's fair. I don't want to take away that functionality so I'll
    take a second look and try to get that working in the parser.

    —
    Reply to this email directly or view it on GitHub
    #7 (comment).

  15. jimthedev commented on Oct 15, 2015

    @jimthedev
    Member

    Excellent. Thanks for taking the time to describe your use cases.

  16. jimthedev commented on Oct 16, 2015

    @jimthedev
    Member

    Ok, I have improved it slightly. You can do git-cz -a (notice that -m is missing) which will add the files before going through the normal commitizen prompts process. The reason you can't add -m in is that since we're filling in the message for you based on your inputs, we show you an error because your input doesn't make sense. We can work on this more and I'll outline this as a known issue in the docs, but I just wanted to document why this choice was made somewhere.

  17. kentcdodds commented on Oct 16, 2015

    @kentcdodds
    MemberAuthor

    Looks like a perfect solution to me 👍

    On Thu, Oct 15, 2015 at 9:08 PM Jim Cummins notifications@github.com
    wrote:

    Ok, I have improved it slightly. You can do git-cz -a (notice that -m is
    missing) which will add the files before going through the normal
    commitizen prompts process. The reason you can't add -m in is that since
    we're filling in the message for you based on your inputs, we show you an
    error because your input doesn't make sense. We can work on this more and
    I'll outline this as a known issue in the docs, but I just wanted to
    document why this choice was made somewhere.

    —
    Reply to this email directly or view it on GitHub
    #7 (comment).

  18. sebastienbarre commented on Oct 16, 2015

    @sebastienbarre

    Nice.
    Minor. This worked for me:

    $ ./node_modules/.bin/git-cz -a
    

    This didn't:

    $ npm run commit -- -a
    > git-cz "-a"
    

    where, in package.json:

      "scripts": {
        "commit": "git-cz",
    

    This is minor of course. I could add -a in the script.

  19. jimthedev commented on Oct 16, 2015

    @jimthedev
    Member

    Ah, good to know. Reopening for now and will work on for 2.x

    Edit, no milestone for this just yet.

  20. modified the milestones: 2.0.0, Unscheduled on Oct 16, 2015
  21. jimthedev commented on Oct 28, 2015

    @jimthedev
    Member

    I just tried this in 2.3.0 and npm run commit -- -a seemed to work for me. I'd made a few changes since the last time we spoke. Can you try again @sebastienbarre. I am on npm 2 and node 0.12.7.

  22. sebastienbarre commented on Oct 29, 2015

    @sebastienbarre

    @jimthedev I confirm it works for me as well. Thx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions