Skip to content

Recommend pedantic git commits #2

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

Open
wants to merge 2 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
6 changes: 3 additions & 3 deletions LICENSE → MIT-LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015 Adam Bullmer
Copyright (c) 2008 Tim Harper (git.tmbundle)
Copyright (c) 2015 Adam Bullmer (borrowed README)
Copyright (c) 2015 Josh Goebel

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
29 changes: 16 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
# Sublime Text git Commit Message Syntax
# Sublime Text Pedantic git Commit Message Syntax

Syntax Highlighting for SublimeText / Text Mate
## Features

- first line should be max 50 characters
- second line should be blank
- any subsequent lines should be max 72 characters

## How to make commits with Sublime Text

For the following options, you'll need to use the appropriate command from below:
**Note** for Windows, you must have `Build 3065` or lated to have command line support
**Note**: for Windows, you must have `Build 3065` or later to have command line support

- Mac / Linux: `subl -w`
- Windows: `subl.exe -w`

### Preferred Method: Edit `.bashrc`

This will allow for more editing options than just the git commit, like editing diffs. This also leaves flexibility as it can be easily overridden, by the `.gitconfig` for example.

Add the following to your `.bashrc`:
On Mac and Linux:

```
export EDITOR="subl -w"
```
export EDITOR="subl -w"

### Alternate Method: Ammend your `.gitconfig`

You can run the following command to let git update your `.gitconfig`

```
git config --global core.editor 'subl -w'
```
git config --global core.editor 'subl -w'

Or add the following line manually to your `.gitconfig`
```
[core]
editor = 'subl -w'
```

[core]
editor = 'subl -w'
78 changes: 0 additions & 78 deletions commit-message.JSON-tmLanguage

This file was deleted.

86 changes: 86 additions & 0 deletions commit-message.YAML-tmLanguage
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# [PackageDev] target_format: plist, ext: tmLanguage
name: Git Commit Message
scopeName: text.git.commit-message
fileTypes: [COMMIT_EDITMSG]
uuid: BFE83C06-8508-44BE-A975-95A57BF619A7

patterns:
- comment: "Comments don't count when looking for the 'first line' of a commit."
name: comment.line.number-sign.git-commit
match: ^\s*(#).*$\n?
captures:
'1': {name: punctuation.definition.comment.git-commit}

- include: '#diff'

- comment: Capture the whole commit message to test the length of the first line.
NB the end pattern is just something to be never matched so the capture continues
until the end of the file.
name: "first-line.git-commit"
begin: ^((.{0,50}\s*)|(.{51,65}\s*)|(.+\s*))$
beginCaptures:
# '1':
# patterns:
# - name: keyword.other.$1.git-commit
# match: \G(fixup|squash)!
'2': { name: 'entity' }
'3': { name: invalid.deprecated.line-too-long.git-commit }
'4': { name: invalid.illegal.line-too-long.git-commit }
end: (?=xxxxxx)123457
patterns:
- comment: capture the second line
begin: ^(()|(.*\s*))$
beginCaptures:
'3': { name: invalid.illegal.line-too-long.git-commit }
end: (?=xxxxxx)123458
patterns:
- name: commit-text.git-commit
match: ^(?:(?!#))((.{0,72})(.*))$\n?
captures:
'3': { name: invalid.illegal.line-too-long.git-commit }
# '4': { name: invalid.illegal.line-too-long.git-commit }
- name: comment.line.number-sign.git-commit
match: (^#)\sYour branch is up-to-date with '(.*)'.
captures:
'2': { name: constant.branch-name }
- name: comment.line.number-sign.git-commit
match: (^#)\s(On branch\s)(.*)$\n?
captures:
'3': { name: constant.branch-name }
- name: comment.line.number-sign.git-commit
match: (^#)\s(.*:)$\n?
captures:
'2': {name: punctuation.definition.comment.git-commit, name: storage}
- name: comment.line.number-sign.git-commit
match: (^#)\s*(modified:.*)$\n?
captures:
'0': {name: markup.changed.git-commit}
'1': {name: punctuation.definition.comment.git-commit}
- name: comment.line.number-sign.git-commit
match: (^#)\s*(new file:.*)$\n?
captures:
'0': {name: markup.inserted.git-commit}
'1': {name: punctuation.definition.comment.git-commit}
- name: comment.line.number-sign.git-commit
match: (^#)\s*(deleted:.*)$\n?
captures:
'0': {name: markup.deleted.git-commit}
'1': {name: punctuation.definition.comment.git-commit}
- name: comment.line.number-sign.git-commit
match: ^\s*(#).*$\n?
captures:
'1': {name: punctuation.definition.comment.git-commit}
- include: '#diff'

repository:
diff:
comment: diff presented at the end of the commit message when using commit -v.
NB the end pattern is just something to be never matched so that the meta continues
until the end of the file.
name: meta.diff.git-commit
begin: diff\ \-\-git
end: (?=xxxxxx)123457
patterns:
- include: source.diff
foldingStartMarker: ^\+\+\+
foldingStopMarker: ^---|^$
Loading