diff options
author | Karthik Nayak <knayak@gitlab.com> | 2023-10-05 12:21:36 +0300 |
---|---|---|
committer | Karthik Nayak <knayak@gitlab.com> | 2023-10-05 15:34:00 +0300 |
commit | b41e8c2724549f229175aac329180fb966bcea66 (patch) | |
tree | 50cb6d5459aa62d34ef7b6f88220a1849ac68037 /proto/shared.proto | |
parent | 5763976d9d8ec1559fc17b1b236c82089c369c4c (diff) |
proto: Replace all "This comment ..." lines
We want to add some linting rules to our proto files, but it seems like
there are a bunch of comments which use the filler line "// This comment
is left unintentionally blank.".
Let's use a python script to replace them with the field, message, rpc,
service or enum name.
Script:
import re
import sys
import os
from glob import glob
result = [y for x in os.walk(".") for y in glob(os.path.join(x[0], '*.proto'))]
for filename in result:
print("doing", filename)
file = open(filename, "r")
lines = file.readlines()
for i, line in enumerate(lines):
if "// This comment is left unintentionally blank." in line:
next_line = lines[i+1]
sub = ""
if re.search("^\s*rpc", next_line):
x = re.findall(r"rpc (\w*)\s?\(", next_line)
if len(x) != 1:
print("error finding rpc name:", next_line, "match:", x)
sys.exit()
sub = x[0]
elif re.search("^\s*message", next_line):
x = re.findall(r"message (\w*)\s?\{", next_line)
if len(x) != 1:
print("error finding message name:", next_line, "match:", x)
sys.exit()
sub = x[0]
elif re.search("^\s*service", next_line):
x = re.findall(r"service (\w*)\s?\{", next_line)
if len(x) != 1:
print("error finding service name:", next_line, "match:", x)
sys.exit()
sub = x[0]
elif re.search("^\s*enum", next_line):
x = re.findall(r"enum (\w*)\s?\{", next_line)
if len(x) != 1:
print("error enum service name:", next_line, "match:", x)
sys.exit()
sub = x[0]
else:
x = re.findall(r"([\w_]*) = \d+", next_line)
if len(x) != 1:
print("error finding field name:", next_line, "match:", x)
sys.exit()
sub = x[0]
lines[i] = line.replace("This comment is left unintentionally blank.", sub + " ...")
file.close()
file = open(filename, "w")
file.writelines(lines)
file.close()
Diffstat (limited to 'proto/shared.proto')
-rw-r--r-- | proto/shared.proto | 92 |
1 files changed, 46 insertions, 46 deletions
diff --git a/proto/shared.proto b/proto/shared.proto index ddbc5ead2..de0a617bd 100644 --- a/proto/shared.proto +++ b/proto/shared.proto @@ -7,17 +7,17 @@ import "lint.proto"; option go_package = "gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb"; -// This comment is left unintentionally blank. +// ObjectType ... enum ObjectType { - // This comment is left unintentionally blank. + // UNKNOWN ... UNKNOWN = 0; // protolint:disable:this ENUM_FIELD_NAMES_PREFIX ENUM_FIELD_NAMES_ZERO_VALUE_END_WITH - // This comment is left unintentionally blank. + // COMMIT ... COMMIT = 1; // protolint:disable:this ENUM_FIELD_NAMES_PREFIX - // This comment is left unintentionally blank. + // BLOB ... BLOB = 2; // protolint:disable:this ENUM_FIELD_NAMES_PREFIX - // This comment is left unintentionally blank. + // TREE ... TREE = 3; // protolint:disable:this ENUM_FIELD_NAMES_PREFIX - // This comment is left unintentionally blank. + // TAG ... TAG = 4; // protolint:disable:this ENUM_FIELD_NAMES_PREFIX } @@ -32,28 +32,28 @@ enum ObjectFormat { OBJECT_FORMAT_SHA256 = 2; } -// This comment is left unintentionally blank. +// SignatureType ... enum SignatureType { - // This comment is left unintentionally blank. + // NONE ... NONE = 0; // protolint:disable:this ENUM_FIELD_NAMES_PREFIX ENUM_FIELD_NAMES_ZERO_VALUE_END_WITH - // This comment is left unintentionally blank. + // PGP ... PGP = 1; // protolint:disable:this ENUM_FIELD_NAMES_PREFIX - // This comment is left unintentionally blank. + // X509 ... X509 = 2; // protolint:disable:this ENUM_FIELD_NAMES_PREFIX - // This comment is left unintentionally blank. + // SSH ... SSH = 3; // protolint:disable:this ENUM_FIELD_NAMES_PREFIX // maybe add X509+TSA or other combinations at a later step } -// This comment is left unintentionally blank. +// Repository ... message Repository { // DEPRECATED: https://gitlab.com/gitlab-org/gitaly/issues/151 reserved 1; reserved "path"; - // This comment is left unintentionally blank. + // storage_name ... string storage_name = 2; - // This comment is left unintentionally blank. + // relative_path ... string relative_path = 3; // Sets the GIT_OBJECT_DIRECTORY envvar on git commands to the value of this field. // It influences the object storage directory the SHA1 directories are created underneath. @@ -95,23 +95,23 @@ message CommitStatInfo { // Corresponds to Gitlab::Git::Commit message GitCommit { - // This comment is left unintentionally blank. + // id ... string id = 1; - // This comment is left unintentionally blank. + // subject ... bytes subject = 2; - // This comment is left unintentionally blank. + // body ... bytes body = 3; - // This comment is left unintentionally blank. + // author ... CommitAuthor author = 4; - // This comment is left unintentionally blank. + // committer ... CommitAuthor committer = 5; - // This comment is left unintentionally blank. + // parent_ids ... repeated string parent_ids = 6; // If body exceeds a certain threshold, it will be nullified, // but its size will be set in body_size so we can know if // a commit had a body in the first place. int64 body_size = 7; - // This comment is left unintentionally blank. + // signature_type ... SignatureType signature_type = 8; // The tree ID will always be filled, even if the tree is empty. In that case // the value will be `4b825dc642cb6eb9a060e54bf8d69288fbee4904`. @@ -135,74 +135,74 @@ message GitCommit { string encoding = 13; } -// This comment is left unintentionally blank. +// CommitAuthor ... message CommitAuthor { - // This comment is left unintentionally blank. + // name ... bytes name = 1; - // This comment is left unintentionally blank. + // email ... bytes email = 2; - // This comment is left unintentionally blank. + // date ... google.protobuf.Timestamp date = 3; - // This comment is left unintentionally blank. + // timezone ... bytes timezone = 4; } -// This comment is left unintentionally blank. +// ExitStatus ... message ExitStatus { - // This comment is left unintentionally blank. + // value ... int32 value = 1; } // Corresponds to Gitlab::Git::Branch message Branch { - // This comment is left unintentionally blank. + // name ... bytes name = 1; - // This comment is left unintentionally blank. + // target_commit ... GitCommit target_commit = 2; } -// This comment is left unintentionally blank. +// Tag ... message Tag { - // This comment is left unintentionally blank. + // name ... bytes name = 1; - // This comment is left unintentionally blank. + // id ... string id = 2; - // This comment is left unintentionally blank. + // target_commit ... GitCommit target_commit = 3; // If message exceeds a certain threshold, it will be nullified, // but its size will be set in message_size so we can know if // a tag had a message in the first place. bytes message = 4; - // This comment is left unintentionally blank. + // message_size ... int64 message_size = 5; - // This comment is left unintentionally blank. + // tagger ... CommitAuthor tagger = 6; - // This comment is left unintentionally blank. + // signature_type ... SignatureType signature_type = 7; } -// This comment is left unintentionally blank. +// User ... message User { - // This comment is left unintentionally blank. + // gl_id ... string gl_id = 1; - // This comment is left unintentionally blank. + // name ... bytes name = 2; - // This comment is left unintentionally blank. + // email ... bytes email = 3; - // This comment is left unintentionally blank. + // gl_username ... string gl_username = 4; // Timezone is the timezone as configured by the user in the web interface. This // timezone may be used when new commits are created via RPC calls. string timezone = 5; } -// This comment is left unintentionally blank. +// ObjectPool ... message ObjectPool { - // This comment is left unintentionally blank. + // repository ... Repository repository = 1 [(gitaly.repository)=true]; } -// This comment is left unintentionally blank. +// PaginationParameter ... message PaginationParameter { // Instructs pagination to start sending results after the provided page // token appears. A page token allows for a generic pattern to uniquely @@ -219,7 +219,7 @@ message PaginationParameter { int32 limit = 2; } -// This comment is left unintentionally blank. +// PaginationCursor ... message PaginationCursor { // To the caller, this is an opaque token to indicate what the caller // should present as a page_token to get subsequent results. |