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

duet-pre-commit + git solo not working #68

Open
bguedel opened this issue Jun 19, 2018 · 7 comments
Open

duet-pre-commit + git solo not working #68

bguedel opened this issue Jun 19, 2018 · 7 comments

Comments

@bguedel
Copy link

bguedel commented Jun 19, 2018

Configuration

export GIT_DUET_GLOBAL=true
export GIT_DUET_CO_AUTHORED_BY=true
export GIT_DUET_SECONDS_AGO_STALE=36000 # 10 hours
git duet-install-hook pre-commit # run this command in a git repository. https://github.com/git-duet/git-duet/issues/61

.git-authors

authors:
  me: MMM EEE
  hm: HHH MMM
  hr: HHH RRR
  tm: TTT MMM
email_template: '{{with replace .Name " " "" -1}}{{toLower .}}{{end}}@domain.com' # firstlast@domain.com

hooks

pre-commit

#!/usr/bin/env bash
exec git duet-pre-commit "$@"

prepare-commit-msg

#!/usr/bin/env bash
exec git duet-prepare-commit-msg "$@"

When doing a git solo

  1. it doesnt remove the previous duet
  2. if it doesnt have the previous duet, it doesnt update the stale seconds -- and refuses to let me commit.
@jszwedko
Copy link
Member

Hi @bguedel,

Thanks for such a detailed issue report!

Unfortunately, I'm having trouble reproducing. I did the following:

$ mkdir tmp
$ cd tmp
$ git init
Initialized empty Git repository in /tmp/tmp/.git/
$ export GIT_DUET_GLOBAL=true
$ export GIT_DUET_CO_AUTHORED_BY=true
$ export GIT_DUET_SECONDS_AGO_STALE=36000
$ git-duet-install-hook pre-commit
$ cat .git/hooks/pre-commit
#!/usr/bin/env bash
exec git duet-pre-commit "$@"
$ cat ~/.git-authors
authors:
  me: MMM EEE
  hm: HHH MMM
  hr: HHH RRR
  tm: TTT MMM
email_template: '{{with replace .Name " " "" -1}}{{toLower .}}{{end}}@domain.com' # firstlast@domain.com
$ git-duet me hm
GIT_AUTHOR_NAME='MMM EEE'
GIT_AUTHOR_EMAIL='mmmeee@domain.com'
GIT_COMMITTER_NAME='HHH MMM'
GIT_COMMITTER_EMAIL='hhhmmm@domain.com'
$ git config --get-regexp 'duet.env' | cat
duet.env.git-author-initials me
duet.env.git-author-name MMM EEE
duet.env.git-author-email mmmeee@domain.com
duet.env.mtime 1529781853
duet.env.git-committer-initials hm
duet.env.git-committer-name HHH MMM
duet.env.git-committer-email hhhmmm@domain.com
$ git solo hr
GIT_AUTHOR_NAME='HHH RRR'
GIT_AUTHOR_EMAIL='hhhrrr@domain.com'
$ git config --get-regexp 'duet.env' | cat
duet.env.git-author-initials hr
duet.env.git-author-name HHH RRR
duet.env.git-author-email hhhrrr@domain.com
duet.env.mtime 1529782004
duet.env.git-committer-initials
duet.env.git-committer-name
duet.env.git-committer-email
$ git-duet -v
0.6.0 ('11f99f70775a68135ece8d22b65273b67901a357')

Is this similar to what you did?

Given the behavior you are seeing, it seems like there is something significant wrong (e.g. maybe it can't parse your config file) that is not giving you an appropriate error message.

@bguedel
Copy link
Author

bguedel commented Jun 27, 2018

I ran the commands and then a commit.

git solo me
git commit -am "test0"
# you need to run git duet or solo

git duet me hr
git commit -am "test1"
# great success

# make a change

git solo me
git commit -am "test2"
# success ++ co-authored-by: hr

in the mean time i have been running

git duet me me

for solo sessions.

I dont remember the full issue from before. Let me clean up my config and hooks and start from scratch to see what happens. Ill try to update back here soon.

@bguedel
Copy link
Author

bguedel commented Jun 27, 2018

I will note that i have the exports in my shell profile. (in this case its zsh)

ill run git duet-install-hook pre-commit 1 time in 1 git repo, then i run git init in other projects.
This shouldnt do anything different, just noting the full test case.

@jszwedko
Copy link
Member

jszwedko commented Jun 28, 2018

Hmm, when you run git solo me do you see something like:

GIT_AUTHOR_NAME='MMM EEE'
GIT_AUTHOR_EMAIL='mmmeee@domain.com'

?

Can you try echo $? after running it to see what the exit code is? Also check the bottom of ~/.gitconfg to see if it added something like:

[duet "env"]
        git-author-initials = me
        git-author-name = MMM EEE
        git-author-email = mmmeee@domain.com

@naokiri
Copy link
Contributor

naokiri commented Nov 1, 2019

Hi, I guess this behaviour has been fixed by #82 and will be applied in future version. You can try exporting the environment variable GIT_DUET_DEFAULT_UPDATE=1 to use that feature now.

@avonengel
Copy link

avonengel commented Apr 2, 2020

Hi, I guess this behaviour has been fixed by #82 and will be applied in future version. You can try exporting the environment variable GIT_DUET_DEFAULT_UPDATE=1 to use that feature now.

I have the same issue as @bguedel, and running git solo <your initials> seems to work. Not sure which version is installed on this machine or which one contains #82, yet. So can't say if this issue is fixed already or not - just wanted to mention that using git solo with author initials is a workaround.

@davidcamarena
Copy link

same issues here (having the pre-commit hook), solution by @avonengel works for me and removes the commiter data so the commits shows I'm the only developer after solo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants