git » chasquid » commit 8ded1f6

Auto-format protobuf files

author Alberto Bertogli
2023-10-03 22:29:21 UTC
committer Alberto Bertogli
2023-10-03 22:34:23 UTC
parent d57037273c14a99cb27d0a4af55d3e1da1415626

Auto-format protobuf files

This patch runs clang-format on the protobuf files, and also adds a
Makefile target for auto-formatting code (Go and protobuf) for
convenience.

.clang-format +4 -0
.gitignore +1 -0
Makefile +6 -1
internal/config/config.proto +5 -4
internal/queue/queue.proto +4 -5

diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..a7209d9
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,4 @@
+Language: Proto
+BasedOnStyle: Google
+IndentWidth: 8
+UseTab: AlignWithSpaces
diff --git a/.gitignore b/.gitignore
index 229362a..2c3ea03 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,7 @@
 # Exceptions to the rules above: files we care about that would otherwise be
 # excluded.
 !.gitignore
+!.clang-format
 !.github/
 
 # The binaries.
diff --git a/Makefile b/Makefile
index 7fa0605..67f45b4 100644
--- a/Makefile
+++ b/Makefile
@@ -55,6 +55,11 @@ install-config-skeleton:
 		chown -v mail:mail /var/lib/chasquid ; \
 	fi
 
+fmt:
+	go vet ./...
+	gofmt -s -w .
+	clang-format -i $(shell find . -iname '*.proto')
 
 .PHONY: chasquid test \
-	chasquid-util smtp-check mda-lmtp dovecot-auth-cli
+	chasquid-util smtp-check mda-lmtp dovecot-auth-cli \
+	fmt
diff --git a/internal/config/config.proto b/internal/config/config.proto
index b7a55b9..4fd143c 100644
--- a/internal/config/config.proto
+++ b/internal/config/config.proto
@@ -28,7 +28,8 @@ message Config {
 
 	// Addresses to listen on for submission-over-TLS (usually port 465).
 	// Default: "systemd", which means systemd passes sockets to us.
-	// systemd sockets must be named with "FileDescriptorName=submission_tls".
+	// systemd sockets must be named with
+	// "FileDescriptorName=submission_tls".
 	repeated string submission_over_tls_address = 5;
 
 	// Address for the monitoring http server.
@@ -37,9 +38,9 @@ message Config {
 	string monitoring_address = 6;
 
 	// Mail delivery agent (MDA, also known as LDA) to use.
-	// This should point to the binary to use to deliver email to local users.
-	// The content of the email will be passed via stdin.
-	// If it exits unsuccessfully, we assume the mail was not delivered.
+	// This should point to the binary to use to deliver email to local
+	// users. The content of the email will be passed via stdin. If it exits
+	// unsuccessfully, we assume the mail was not delivered.
 	// Default: "maildrop".
 	string mail_delivery_agent_bin = 7;
 
diff --git a/internal/queue/queue.proto b/internal/queue/queue.proto
index 40dc0a5..ce3adab 100644
--- a/internal/queue/queue.proto
+++ b/internal/queue/queue.proto
@@ -49,10 +49,9 @@ message Recipient {
 // We used to use the well-known type, but the dependency makes packaging much
 // more convoluted and adds very little value, so we now just include it here.
 message Timestamp {
-  // Represents seconds of UTC time since Unix epoch.
-  int64 seconds = 1;
+	// Represents seconds of UTC time since Unix epoch.
+	int64 seconds = 1;
 
-  // Non-negative fractions of a second at nanosecond resolution.
-  int32 nanos = 2;
+	// Non-negative fractions of a second at nanosecond resolution.
+	int32 nanos = 2;
 }
-