Skip to content

Add Option to Assign Color for Each Commit #220

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ If this option is selected, only the last word of the author's name will be disp

Default date format is `YYYY-MM-DD`. This feature is backed by [moment.js](http://momentjs.com/). Any formats [supported by moment](http://momentjs.com/docs/#/displaying/format/) are valid here.

### Color commit authors
If this option is selected, the commit authors will appear with a unique color to make them easily recognisable.
### Color Commit
If this option is selected, the commit authors or commit will appear with a unique color to make them easily recognisable.

### Custom Remote Repo Url
This plugin will first check to see if your repo is backed by **GitHub**, **Bitbucket**, or **GitLab** so nothing is required if your repo is hosted on one of these.
Expand Down
12 changes: 10 additions & 2 deletions lib/components/BlameLine.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,20 @@ export default function BlameLine(props) {
showOnlyLastNames,
showHash,
viewCommitUrl,
colorCommitAuthors,
colorCommit,
} = props;

const displayName = showOnlyLastNames ? lastWord(author) : author;
let color;
if (colorCommit === 'hash') {
color = stringToColour(hash);
} else if (colorCommit === 'author') {
color = stringToColour(author);
} else {
color = null;
}
return (
<div className={`blame-line ${className}`} style={{ borderRight: colorCommitAuthors ? `2px solid ${stringToColour(author)}` : 'none' }}>
<div className={`blame-line ${className}`} style={{ borderRight: color ? `2px solid ${color}` : 'none' }}>
<a href={viewCommitUrl}>
{showHash ? <span className="hash">{hash.substring(0, HASH_LENGTH)}</span> : null}
<span className="date">{date}</span>
Expand Down
13 changes: 9 additions & 4 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,13 @@ export default {
type: 'boolean',
default: true,
},
colorCommitAuthors: {
type: 'boolean',
default: false,
},
colorCommit: {
type: 'string',
default: 'NONE',
enum: [
{value: 'NONE', description: 'No Color'},
{value: 'author', description: 'Assign color for each Author'},
{value: 'hash', description: 'Assign color for each commit'}
]
}
};
4 changes: 2 additions & 2 deletions lib/util/BlameGutter.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export default class BlameGutter {
updateLineMarkers(filePath) {
const showOnlyLastNames = atom.config.get('git-blame.showOnlyLastNames');
const showHash = atom.config.get('git-blame.showHash');
const colorCommitAuthors = atom.config.get('git-blame.colorCommitAuthors');
const colorCommit = atom.config.get('git-blame.colorCommit');
return repositoryForEditorPath(filePath)
.then((repo) => {
const blamer = new Blamer(repo);
Expand Down Expand Up @@ -132,7 +132,7 @@ export default class BlameGutter {
viewCommitUrl,
showOnlyLastNames,
showHash,
colorCommitAuthors,
colorCommit,
};

// adding one marker to the first line
Expand Down