0

I’d like to get Git log only users with date condition. Since in our CI/CD pipeline, some commits automatically added, we’d like to purge them.

For example, we’d like to exclude below system accounts and get Git log after 2022-10-01.

sachiko@XXX.co.jp
keiko@XXX.co.jp
iori@XXX.co.jp
… other 100 user accounts <-- our pick up target

concourse@XXX.co.jp <-- system account, purge target
git@localhost <-- system acount, purge target
devXXXXau <-- system acount, purge target

trial :
git log --date=iso --pretty=format:"[%ad] %h %an" --author='^(?!concourse@XXX.co.jp|git@localhost|devXXXXau).*$' --perl-regexp --after '2022/10/01'

result:
[2022-11-11 19:40:48 +0900] 463aab83 sachiko<E7><B8><B2><C2><80>--author='^(?!concourse@XXX.co.jp|git@localhost|devXXXXau).*$'
[2022-11-11 19:40:49 +0900] 463aab84 git@localhost<E7><B8><B2><C2><80>--author='^(?!concourse@XXX.co.jp|git@localhost|devXXXXau).*$'
[2022-11-11 19:40:56 +0900] 463aab85 iori<E7><B8><B2><C2><80>--author='^(?!concourse@XXX.co.jp|git@localhost|devXXXXau).*$'

We'd like pick up only users log, sachiko and iori, to purge all system log, but it's not working so far.

And also I’d just like to get only “[2022-11-11 19:40:47 +0900] 463aab83 sachiko”, author date, commit hash, author.

halfer
  • 19,824
  • 17
  • 99
  • 186
Sachiko
  • 808
  • 1
  • 12
  • 31
  • 3
    take a look at this: https://stackoverflow.com/questions/6889830/equivalence-of-git-log-exclude-author. – eftshift0 Nov 11 '22 at 15:06
  • 1
    Instead "exclude many" (even in better form `--author='^((?!concourse|git|dev).*)$'`)` maybe to have "include one"? – Lazy Badger Nov 11 '22 at 15:50
  • @Lazy Badger thanks for your kind comment. Sorry for my bad example, I'd like to pick up other 100 users' log. I'll edit my sample. – Sachiko Nov 12 '22 at 00:00
  • 1
    ACK, cleaner now. For case "pick up a lot, purge a few" please try my shortened regexp. Your code *may not work* due to **unescaped special char in regexp**, namely - dots in email – Lazy Badger Nov 12 '22 at 06:46

1 Answers1

0

Thanks to @eftshift0 and @Lazy Badger I could exclude several accounts as follows;

git log --date=local --pretty=format:"[%ad] %h %an : %s"  --after '2022/10/01' --author="\(concourse@xxxxx.co.jp\)\|\(devxxxxxxau\)\|\(git@localhost\)" --invert-grep

Hopefully, it can be a little help for someone.

Sachiko
  • 808
  • 1
  • 12
  • 31