Skip to content

Commit

Permalink
doc: Add documentation on how to handle multiple contributor names vi…
Browse files Browse the repository at this point in the history
…a .mailmap file
  • Loading branch information
msuzoagu committed Aug 27, 2024
1 parent 9939ab7 commit ed47551
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions Sources/SPIManifest/Documentation.docc/MailMapFile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Handling Multiple Contributor Names with .mailmap

### Introduction

In some repositories, contributors may commit from different devices or with
different configurations, leading to multiple names appearing for the same
contributor. For example, a repository might show “John Doe” and “Johnathan
Doe” as two separate contributors, even though they are the same person.

This guide explains how to use a __.mailmap__ file to normalize commits and
ensure a single contributor name appears in your Swift Package.

### Solution
A __.mailmap file__ allows contributors to map multiple email addresses and
names to a single canonical name and email address. [Git](https://git-scm.com/docs/gitmailmap#:~:text=mailmap%20exists%20at%20the%20toplevel,real%20names%20and%20email%20addresses.)
provides a description of what a __.mailmap__ file is and a good example
can be found in [Swift-NIO](https://github.com/apple/swift-nio/blob/main/.mailmap).

#### Step-by-Step Guide
1. Create a .mailmap file in the root of your repository.
2. Add mappings in the .mailmap file to normalize the contributor names and
email addresses.
- The format is: `Proper Name <[email protected]> <[email protected]>`
- example: `John Doe <[email protected]> <[email protected]>`
- this is an example of a __.mailmap__ file:
```
John Doe <[email protected]> <[email protected]>
John Doe <[email protected]> <[email protected]>
```
3. Add and commit the __.mailmap__ file:
```
git add .mailmap
git commit -m "Add .mailmap to normalize contributor names"
git push origin main
```

4. Once the __.mailmap__ file is in place, the contributor list should reflect
the normalized names.

### Additional Configuration
If the .mailmap file does not completely resolve the issue, you can override the
contributor list directly in the manifest. You can specify the contributors in
the manifest as follows:
```swift
.metadata.authors([
.author(name: "John Doe", email: "[email protected]")
])
```
For more details refer to the [SPI Manifest Documentation](https://swiftpackageindex.com/swiftpackageindex/spimanifest/0.17.2/documentation/spimanifest/manifest/metadata-swift.struct/authors)

0 comments on commit ed47551

Please sign in to comment.