|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* Copyright (C) 2016 Billie Thompson |
|
7
|
|
|
* |
|
8
|
|
|
* This software may be modified and distributed under the terms |
|
9
|
|
|
* of the MIT license. See the LICENSE file for details. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace PurpleBooth\GitLintValidators\Status; |
|
13
|
|
|
|
|
14
|
|
|
use PurpleBooth\GitLintValidators\Validator\SoftLimitTheTitleLengthTo50CharactersValidator; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* This is the status returned when the SoftLimitTheTitleLengthTo50CharactersValidator identifies a problem. |
|
18
|
|
|
* |
|
19
|
|
|
* @see SoftLimitTheTitleLengthTo50CharactersValidator |
|
20
|
|
|
*/ |
|
21
|
|
|
class SoftLimitTheTitleLengthTo50CharactersStatus implements Status |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* Get the importance of this status. |
|
25
|
|
|
* |
|
26
|
|
|
* The lower the value the less important it is, the higher the more important. |
|
27
|
|
|
* |
|
28
|
|
|
* @return int |
|
29
|
|
|
*/ |
|
30
|
|
|
public function getWeight(): int |
|
31
|
|
|
{ |
|
32
|
|
|
return Status::WEIGHT_WARN; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* A human readable message that describes this state. |
|
37
|
|
|
* |
|
38
|
|
|
* This will be displayed to the user via the GitHub state |
|
39
|
|
|
* |
|
40
|
|
|
* @return string |
|
41
|
|
|
*/ |
|
42
|
|
|
public function getMessage(): string |
|
43
|
|
|
{ |
|
44
|
|
|
return 'Looks good, but can you shorten the subject of the commit message to 50 characters or less?'; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Is true if the status is one that should not be taken as indicative of a incorrectly formatted message. |
|
49
|
|
|
* |
|
50
|
|
|
* @return bool |
|
51
|
|
|
*/ |
|
52
|
|
|
public function isPositive(): bool |
|
53
|
|
|
{ |
|
54
|
|
|
return true; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* The GitHub equivalent of this state. |
|
59
|
|
|
* |
|
60
|
|
|
* Can be one of pending, success, error, or failure. |
|
61
|
|
|
* |
|
62
|
|
|
* @return string |
|
63
|
|
|
*/ |
|
64
|
|
|
public function getState(): string |
|
65
|
|
|
{ |
|
66
|
|
|
return Status::STATE_SUCCESS; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* Get a URL with further explanation about this commit message status. |
|
71
|
|
|
* |
|
72
|
|
|
* @return string |
|
73
|
|
|
*/ |
|
74
|
|
|
public function getDetailsUrl(): string |
|
75
|
|
|
{ |
|
76
|
|
|
return 'http://chris.beams.io/posts/git-commit/#limit-50'; |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
|