vuepress / core

Vue-Powered Static Site Generator
https://vuepress.vuejs.org
MIT License
2.17k stars 923 forks source link

feat(plugin-git): remove duplicate no-reply contributors #1364

Closed lukemassa closed 12 months ago

lukemassa commented 1 year ago

Before submitting the PR, please make sure you do the following

What is the purpose of this pull request?

Description

A user might use multiple mechanisms of contributing code, some directly using their username and email, and others automated, typically with a "noreply" email address. Right now, this causes pages that use the "contributor" to have this somewhat awkward field:

rendered

This change treats the noreply addresses as the "same contributor", if one exists with the same name.

If a file has no such "noreply" addresses, or if there is no corresponding "normal" contributor, the field is unchanged.

Discussion: https://github.com/vuepress/vuepress-next/discussions/1336

Changes

Before

plugin-git % pnpm build && node -e 'import("./lib/node/utils/getContributors.js").then((mod)=>{mod.getContributors(["runatlantis.io/docs/README.md"], "/Users/lukemassa/atlantis").then((value)=>{console.log(value)})})'

> @vuepress/plugin-git@2.0.0-beta.63 build /Users/lukemassa/vuepress-next/ecosystem/plugin-git
> tsc -b tsconfig.build.json

[
  { name: 'Luke Kysow', email: 'lkysow@gmail.com', commits: 6 },
  {
    name: 'Luke Kysow',
    email: '1034429+lkysow@users.noreply.github.com',
    commits: 2
  }
]

After

plugin-git % pnpm build && node -e 'import("./lib/node/utils/getContributors.js").then((mod)=>{mod.getContributors(["runatlantis.io/docs/README.md"], "/Users/lukemassa/atlantis").then((value)=>{console.log(value)})})'

> @vuepress/plugin-git@2.0.0-beta.63 build /Users/lukemassa/vuepress-next/ecosystem/plugin-git
> tsc -b tsconfig.build.json

[ { name: 'Luke Kysow', email: 'lkysow@gmail.com', commits: 6 } ]
meteorlxy commented 1 year ago

@lukemassa Sorry for delay. Have you checked this one? https://github.com/vuepress/vuepress-next/issues/537

Mister-Hope commented 1 year ago

I am actually "upvote" for this kind of changes, it's common to merge a pr and create a new commit through things like github, and people can choose to hide their emails:

image

It's definitely better if we can recognize and remove them in plugin.

meteorlxy commented 1 year ago

Maybe we'd better merge the commits count instead of simply remove it?

Mister-Hope commented 1 year ago

Yes, we can merge it if a same name already exists in same file commit, and maybe just remove the email field if not found.

lukemassa commented 1 year ago

I added some code to sum up the contributions:

plugin-git % pnpm build && node -e 'import("./lib/node/utils/getContributors.js").then((mod)=>{mod.getContributors(["runatlantis.io/docs/README.md"], "/Users/lukemassa/atlantis").then((value)=>{console.log(value)})})'

> @vuepress/plugin-git@2.0.0-beta.63 build /Users/lukemassa/vuepress-next/ecosystem/plugin-git
> tsc -b tsconfig.build.json

[ { name: 'Luke Kysow', email: 'lkysow@gmail.com', commits: 8 } ]
meteorlxy commented 12 months ago

Thanks for your contributions! ❤️