diff --git a/LICENSE b/MIT-LICENSE similarity index 89% rename from LICENSE rename to MIT-LICENSE index f2ba501..557a0a7 100644 --- a/LICENSE +++ b/MIT-LICENSE @@ -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 diff --git a/README.md b/README.md index 3106c5b..5de2792 100644 --- a/README.md +++ b/README.md @@ -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' diff --git a/commit-message.JSON-tmLanguage b/commit-message.JSON-tmLanguage deleted file mode 100644 index 7056d91..0000000 --- a/commit-message.JSON-tmLanguage +++ /dev/null @@ -1,78 +0,0 @@ -// [PackageDev] target_format: plist, ext: tmLanguage -{ - "name": "Commit Message", - "scopeName": "text.git-commit-message", - "fileTypes": ["COMMIT_EDITMSG"], - "uuid": "6e83eb4a-b9de-42e5-a5fb-6371dac1c37e", - - "patterns": [{ - "name": "comment.line.number-sign.git-commit-message", - "begin": "^#", - "beginCaptures": { - "0": { "name": "punctuation.definition.comment.git-commit-message" } - }, - "end": "$", - "patterns": [{ - "name": "comment.line.on-branch.git-commit-message", - "match": "(?:On branch )([^ ]+)", - "captures": { - "1": { "name": "support.function.branch.git-commit-message" } - } - }, - { - "name": "comment.line.on-branch.git-commit-message", - "match": "Your branch .* '([^ ']+)'", - "captures": { - "1": { "name": "support.function.branch.git-commit-message" } - } - }, - { - "name": "comment.line.untracked.git-commit-message", - "begin": " Untracked files:", - "beginCaptures": { - "0": { "name": "entity.definition.untracked.git-commit-message" } - }, - "end": "^#$", - "patterns": [{ - "name": "comment.line.untracked-file.git-commit-message", - "match": "\t(.*)$", - "captures": { - "1": { "name": "support.function.file-status.git-commit-message"}, - "2": { "name": "constant.character.branch.git-commit-message" } - } - }] - }, - { - "name": "comment.line.discarded.git-commit-message", - "begin": " Change(?:s not staged for commit|d but not updated):", - "beginCaptures": { - "0": { "name": "entity.definition.discarded.git-commit-message" } - }, - "end": "^#$", - "patterns": [{ - "name": "comment.line.discarded.git-commit-message", - "match": "\t([^:]+):(.*)$", - "captures": { - "1": { "name": "support.function.file-status.git-commit-message"}, - "2": { "name": "constant.character.branch.git-commit-message" } - } - }] - }, - { - "name": "comment.line.selected.git-commit-message", - "begin": " Changes to be committed:", - "beginCaptures": { - "0": { "name": "entity.definition.selected.git-commit-message" } - }, - "end": "^#$", - "patterns": [{ - "name": "comment.line.selected.git-commit-message", - "match": "\t([^:]+):(.*)$", - "captures": { - "1": { "name": "support.function.file-status.git-commit-message"}, - "2": { "name": "constant.character.branch.git-commit-message" } - } - }] - }] - }] -} diff --git a/commit-message.YAML-tmLanguage b/commit-message.YAML-tmLanguage new file mode 100644 index 0000000..9aae899 --- /dev/null +++ b/commit-message.YAML-tmLanguage @@ -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: ^---|^$ diff --git a/commit-message.tmLanguage b/commit-message.tmLanguage index 073d5cf..8a8edc1 100644 --- a/commit-message.tmLanguage +++ b/commit-message.tmLanguage @@ -6,175 +6,240 @@ COMMIT_EDITMSG + foldingStartMarker + ^\+\+\+ + foldingStopMarker + ^---|^$ name - Commit Message + Git Commit Message patterns - begin - ^# - beginCaptures + captures - 0 + 1 name - punctuation.definition.comment.git-commit-message + punctuation.definition.comment.git-commit - end - $ + comment + Comments don't count when looking for the 'first line' of a commit. + match + ^\s*(#).*$\n? name - comment.line.number-sign.git-commit-message - patterns - + comment.line.number-sign.git-commit + + + include + #diff + + + begin + ^((.{0,50}\s*)|(.{51,65}\s*)|(.+\s*))$ + beginCaptures + + 2 - captures - - 1 - - name - support.function.branch.git-commit-message - - - match - (?:On branch )([^ ]+) name - comment.line.on-branch.git-commit-message + entity + 3 - captures - - 1 - - name - support.function.branch.git-commit-message - - - match - Your branch .* '([^ ']+)' name - comment.line.on-branch.git-commit-message + invalid.deprecated.line-too-long.git-commit + 4 + + name + invalid.illegal.line-too-long.git-commit + + + 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. + end + (?=xxxxxx)123457 + name + first-line.git-commit + patterns + begin - Untracked files: + ^(()|(.*\s*))$ beginCaptures - 0 + 3 name - entity.definition.untracked.git-commit-message + invalid.illegal.line-too-long.git-commit + comment + capture the second line end - ^#$ - name - comment.line.untracked.git-commit-message + (?=xxxxxx)123458 patterns captures - 1 + 3 name - support.function.file-status.git-commit-message + invalid.illegal.line-too-long.git-commit + + match + ^(?:(?!#))((.{0,72})(.*))$\n? + name + commit-text.git-commit + + + captures + 2 name - constant.character.branch.git-commit-message + constant.branch-name match - (.*)$ + (^#)\sYour branch is up-to-date with '(.*)'. name - comment.line.untracked-file.git-commit-message + comment.line.number-sign.git-commit - - - - begin - Change(?:s not staged for commit|d but not updated): - beginCaptures - - 0 + captures + + 3 + + name + constant.branch-name + + + match + (^#)\s(On branch\s)(.*)$\n? name - entity.definition.discarded.git-commit-message + comment.line.number-sign.git-commit - - end - ^#$ - name - comment.line.discarded.git-commit-message - patterns - captures - 1 + 2 name - support.function.file-status.git-commit-message + storage - 2 + + match + (^#)\s(.*:)$\n? + name + comment.line.number-sign.git-commit + + + captures + + 0 name - constant.character.branch.git-commit-message + markup.changed.git-commit + + 1 + + name + punctuation.definition.comment.git-commit match - ([^:]+):(.*)$ + (^#)\s*(modified:.*)$\n? name - comment.line.discarded.git-commit-message + comment.line.number-sign.git-commit - - - - begin - Changes to be committed: - beginCaptures - - 0 + captures + + 0 + + name + markup.inserted.git-commit + + 1 + + name + punctuation.definition.comment.git-commit + + + match + (^#)\s*(new file:.*)$\n? name - entity.definition.selected.git-commit-message + comment.line.number-sign.git-commit - - end - ^#$ - name - comment.line.selected.git-commit-message - patterns - captures + 0 + + name + markup.deleted.git-commit + 1 name - support.function.file-status.git-commit-message + punctuation.definition.comment.git-commit - 2 + + match + (^#)\s*(deleted:.*)$\n? + name + comment.line.number-sign.git-commit + + + captures + + 1 name - constant.character.branch.git-commit-message + punctuation.definition.comment.git-commit match - ([^:]+):(.*)$ + ^\s*(#).*$\n? name - comment.line.selected.git-commit-message + comment.line.number-sign.git-commit + + + include + #diff + repository + + diff + + begin + diff\ \-\-git + 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. + end + (?=xxxxxx)123457 + name + meta.diff.git-commit + patterns + + + include + source.diff + + + + scopeName - text.git-commit-message + text.git.commit-message uuid - 6e83eb4a-b9de-42e5-a5fb-6371dac1c37e + BFE83C06-8508-44BE-A975-95A57BF619A7