diff --git a/cmd/login.go b/cmd/login.go new file mode 100644 index 0000000..3c46be8 --- /dev/null +++ b/cmd/login.go @@ -0,0 +1,59 @@ +/* +Copyright © 2023 NAME HERE +*/ +package cmd + +import ( + "fmt" + "sync" + + "github.com/cocoide/commitify/internal/gateway" + "github.com/cocoide/commitify/internal/usecase" + "github.com/fatih/color" + "github.com/spf13/cobra" +) + +const ( + DeviceActivateURL = "https://github.com/login/device" +) + +var loginCmd = &cobra.Command{ + Use: "login", + Short: "login by github", + Long: `by login you can use auto pull request feature`, + Run: func(cmd *cobra.Command, args []string) { + httpClient := gateway.NewHttpClient() + u := usecase.NewLoginCmdUsecase(httpClient) + res, err := u.BeginGithubSSO() + if err != nil { + fmt.Printf("ログイン中にエラーが発生: %v", err) + } + + var wg sync.WaitGroup + wg.Add(1) + + errChan := make(chan error, 1) + + go func() { + defer wg.Done() + + req := &usecase.ScheduleVerifyAuthRequest{ + DeviceCode: res.DeviceCode, Interval: res.Interval, ExpiresIn: res.ExpiresIn} + err := u.ScheduleVerifyAuth(req) + errChan <- err + }() + fmt.Printf("以下のページで認証コード『%s』を入力して下さい。\n", res.UserCode) + fmt.Printf(color.HiCyanString("➡️ %s\n"), DeviceActivateURL) + wg.Wait() + err = <-errChan + if err != nil { + fmt.Printf("🚨認証エラーが発生: %v", err) + } else { + fmt.Printf("**🎉認証が正常に完了**\n") + } + }, +} + +func init() { + rootCmd.AddCommand(loginCmd) +} diff --git a/cmd/suggest.go b/cmd/suggest.go index b5bdfd2..bf5e38b 100644 --- a/cmd/suggest.go +++ b/cmd/suggest.go @@ -129,7 +129,7 @@ func NewSuggestModel() *suggestModel { if err != nil { log.Fatalf("設定ファイルの読み込みができませんでした") } - switch config.WithGptRequestLocation() { + switch config.GptRequestLocation() { case entity.Client: nlp := gateway.NewOpenAIGateway(context.Background()) commitMessageService = gateway.NewClientCommitMessageGateway(nlp) diff --git a/internal/entity/config.go b/internal/entity/config.go index a11a39b..de50fb5 100644 --- a/internal/entity/config.go +++ b/internal/entity/config.go @@ -3,7 +3,7 @@ package entity import ( "encoding/json" "fmt" - "github.com/cocoide/commitify-grpc-server/pkg/pb" + pb "github.com/cocoide/commitify/proto/gen" "github.com/spf13/viper" "os" ) @@ -38,6 +38,7 @@ type Config struct { UseLanguage int `json:"UseLanguage"` CommitFormat int `json:"CommitFormat"` AISource int `json:"AISource"` + GithubToken string `json:"GithubToken"` } func (c *Config) Config2PbVars() (pb.CodeFormatType, pb.LanguageType) { @@ -81,7 +82,7 @@ func ReadConfig() (Config, error) { return result, nil } -func WriteConfig(config Config) error { +func (c Config) WriteConfig() error { homePath, err := os.UserHomeDir() if err != nil { return err @@ -91,7 +92,7 @@ func WriteConfig(config Config) error { viper.SetConfigName("config") viper.SetConfigType("yaml") configMap := make(map[string]interface{}) - configBytes, err := json.Marshal(config) + configBytes, err := json.Marshal(c) if err != nil { return fmt.Errorf("error marshalling config: %s", err.Error()) } @@ -108,6 +109,11 @@ func WriteConfig(config Config) error { return nil } +func (c *Config) WithGithubToken(token string) *Config { + c.GithubToken = token + return c +} + func SaveConfig(configIndex, updateConfigParamInt int, updateConfigParamStr string) error { currentConfig, err := ReadConfig() if err != nil { @@ -125,7 +131,7 @@ func SaveConfig(configIndex, updateConfigParamInt int, updateConfigParamStr stri currentConfig.AISource = updateConfigParamInt } - err = WriteConfig(currentConfig) + err = currentConfig.WriteConfig() if err != nil { return err } @@ -133,7 +139,7 @@ func SaveConfig(configIndex, updateConfigParamInt int, updateConfigParamStr stri return nil } -func (c *Config) WithGptRequestLocation() GptRequestLocation { +func (c *Config) GptRequestLocation() GptRequestLocation { switch c.AISource { case 0: return Server diff --git a/internal/gateway/grpc.go b/internal/gateway/grpc.go index d0391b1..4d436a8 100644 --- a/internal/gateway/grpc.go +++ b/internal/gateway/grpc.go @@ -2,9 +2,9 @@ package gateway import ( "crypto/tls" - "github.com/cocoide/commitify-grpc-server/pkg/pb" "github.com/cocoide/commitify/internal/entity" "github.com/cocoide/commitify/internal/service" + pb "github.com/cocoide/commitify/proto/gen" "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/credentials" diff --git a/internal/gateway/http_client.go b/internal/gateway/http_client.go new file mode 100644 index 0000000..283183e --- /dev/null +++ b/internal/gateway/http_client.go @@ -0,0 +1,103 @@ +package gateway + +import ( + "fmt" + "io" + "net/http" + "strconv" +) + +type HttpClient struct { + client *http.Client + endpoint string + headers map[string]string + params map[string]interface{} + body io.Reader +} + +func NewHttpClient() *HttpClient { + return &HttpClient{ + client: &http.Client{}, + headers: make(map[string]string), + params: make(map[string]interface{}), + } +} + +func (h *HttpClient) WithBaseURL(baseURL string) *HttpClient { + h.endpoint = baseURL + return h +} + +func (h *HttpClient) WithBearerToken(token string) *HttpClient { + h.headers["Authorization"] = fmt.Sprintf("Bearer %s", token) + return h +} + +func (h *HttpClient) WithPath(path string) *HttpClient { + h.endpoint = h.endpoint + "/" + path + return h +} + +func (h *HttpClient) WithParam(key string, value interface{}) *HttpClient { + h.params[key] = value + return h +} + +type HttpMethod int + +const ( + GET HttpMethod = iota + 1 + POST + DELTE + PUT +) + +func (h *HttpClient) Execute(method HttpMethod) ([]byte, error) { + var methodName string + switch method { + case GET: + methodName = "GET" + case POST: + methodName = "POST" + case DELTE: + methodName = "DELETE" + case PUT: + methodName = "PUT" + } + client := h.client + + req, err := http.NewRequest(methodName, h.endpoint, h.body) + if err != nil { + return nil, err + } + + for k, v := range h.headers { + req.Header.Add(k, v) + } + + query := req.URL.Query() + for key, value := range h.params { + switch v := value.(type) { + case string: + query.Add(key, v) + case int: + query.Add(key, strconv.Itoa(v)) + case bool: + query.Add(key, strconv.FormatBool(v)) + default: + return nil, fmt.Errorf("Failed to parse param value: %v", value) + } + } + req.URL.RawQuery = query.Encode() + resp, err := client.Do(req) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + body, err := io.ReadAll(resp.Body) + if err != nil { + return nil, err + } + return body, nil +} diff --git a/internal/usecase/login_cmd.go b/internal/usecase/login_cmd.go new file mode 100644 index 0000000..fe76056 --- /dev/null +++ b/internal/usecase/login_cmd.go @@ -0,0 +1,120 @@ +package usecase + +import ( + "fmt" + "github.com/cocoide/commitify/internal/entity" + "github.com/cocoide/commitify/internal/gateway" + "net/url" + "strconv" + "time" +) + +const ( + GithubClientID = "b27d87c28752d2363922" + GithubScope = "repo" + GrantType = "urn:ietf:params:oauth:grant-type:device_code" +) + +type LoginCmdUsecase struct { + http *gateway.HttpClient +} + +func NewLoginCmdUsecase(http *gateway.HttpClient) *LoginCmdUsecase { + http.WithBaseURL("https://github.com/login") + return &LoginCmdUsecase{http: http} +} + +type BeginGithubSSOResponse struct { + DeviceCode string + UserCode string + Interval int + ExpiresIn int +} + +func (u *LoginCmdUsecase) BeginGithubSSO() (*BeginGithubSSOResponse, error) { + b, err := u.http.WithPath("device/code"). + WithParam("client_id", GithubClientID). + WithParam("scope", GithubScope). + Execute(gateway.POST) + if err != nil { + return nil, err + } + values, err := url.ParseQuery(string(b)) + if err != nil { + return nil, err + } + deviceCode := values.Get("device_code") + userCode := values.Get("user_code") + expiresIn, err := strconv.Atoi(values.Get("expires_in")) + if err != nil { + return nil, err + } + interval, err := strconv.Atoi(values.Get("interval")) + if err != nil { + return nil, err + } + if deviceCode == "" || userCode == "" { + return nil, fmt.Errorf("failed to parse code") + } + return &BeginGithubSSOResponse{ + DeviceCode: deviceCode, + UserCode: userCode, + ExpiresIn: expiresIn, + Interval: interval, + }, nil +} + +type ScheduleVerifyAuthRequest struct { + DeviceCode string + Interval int + ExpiresIn int +} + +func (u *LoginCmdUsecase) ScheduleVerifyAuth(req *ScheduleVerifyAuthRequest) error { + u.http = gateway.NewHttpClient(). + WithBaseURL("https://github.com/login"). + WithPath("oauth/access_token"). + WithParam("client_id", GithubClientID). + WithParam("device_code", req.DeviceCode). + WithParam("grant_type", GrantType) + + timeout := time.After(time.Duration(req.ExpiresIn) * time.Second) + ticker := time.NewTicker(time.Duration(req.Interval) * time.Second) + defer ticker.Stop() + + for { + select { + case <-timeout: + return fmt.Errorf("認証プロセスがタイムアウトしました") + case <-ticker.C: + b, err := u.http.Execute(gateway.POST) + if err != nil { + return err + } + values, err := url.ParseQuery(string(b)) + if err != nil { + return err + } + accessToken := values.Get("access_token") + if accessToken != "" { + config, err := entity.ReadConfig() + if err != nil { + return err + } + config.WithGithubToken(accessToken) + if err := config.WriteConfig(); err != nil { + return err + } + return nil + } + if newIntervalStr := values.Get("interval"); newIntervalStr != "" { + newInterval, err := strconv.Atoi(newIntervalStr) + if err != nil { + return err + } + ticker.Stop() + ticker = time.NewTicker(time.Duration(newInterval) * time.Second) + } + } + } +} diff --git a/proto/gen/code_type.pb.go b/proto/gen/code_type.pb.go new file mode 100644 index 0000000..a101a56 --- /dev/null +++ b/proto/gen/code_type.pb.go @@ -0,0 +1,191 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v4.24.4 +// source: code_type.proto + +package src + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// CodeFormatType specifies the type of commit message to generate +type CodeFormatType int32 + +const ( + CodeFormatType_UNKNOWN_FORMAT CodeFormatType = 0 + CodeFormatType_NORMAL CodeFormatType = 1 + CodeFormatType_PREFIX CodeFormatType = 2 + CodeFormatType_EMOJI CodeFormatType = 3 +) + +// Enum value maps for CodeFormatType. +var ( + CodeFormatType_name = map[int32]string{ + 0: "UNKNOWN_FORMAT", + 1: "NORMAL", + 2: "PREFIX", + 3: "EMOJI", + } + CodeFormatType_value = map[string]int32{ + "UNKNOWN_FORMAT": 0, + "NORMAL": 1, + "PREFIX": 2, + "EMOJI": 3, + } +) + +func (x CodeFormatType) Enum() *CodeFormatType { + p := new(CodeFormatType) + *p = x + return p +} + +func (x CodeFormatType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (CodeFormatType) Descriptor() protoreflect.EnumDescriptor { + return file_code_type_proto_enumTypes[0].Descriptor() +} + +func (CodeFormatType) Type() protoreflect.EnumType { + return &file_code_type_proto_enumTypes[0] +} + +func (x CodeFormatType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use CodeFormatType.Descriptor instead. +func (CodeFormatType) EnumDescriptor() ([]byte, []int) { + return file_code_type_proto_rawDescGZIP(), []int{0} +} + +// LanguageType specifies the language of the commit message to generate +type LanguageType int32 + +const ( + LanguageType_UNKNOWN_LANGUAGE LanguageType = 0 + LanguageType_ENGLISH LanguageType = 1 + LanguageType_JAPANESE LanguageType = 2 +) + +// Enum value maps for LanguageType. +var ( + LanguageType_name = map[int32]string{ + 0: "UNKNOWN_LANGUAGE", + 1: "ENGLISH", + 2: "JAPANESE", + } + LanguageType_value = map[string]int32{ + "UNKNOWN_LANGUAGE": 0, + "ENGLISH": 1, + "JAPANESE": 2, + } +) + +func (x LanguageType) Enum() *LanguageType { + p := new(LanguageType) + *p = x + return p +} + +func (x LanguageType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (LanguageType) Descriptor() protoreflect.EnumDescriptor { + return file_code_type_proto_enumTypes[1].Descriptor() +} + +func (LanguageType) Type() protoreflect.EnumType { + return &file_code_type_proto_enumTypes[1] +} + +func (x LanguageType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use LanguageType.Descriptor instead. +func (LanguageType) EnumDescriptor() ([]byte, []int) { + return file_code_type_proto_rawDescGZIP(), []int{1} +} + +var File_code_type_proto protoreflect.FileDescriptor + +var file_code_type_proto_rawDesc = []byte{ + 0x0a, 0x0f, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x12, 0x09, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x2a, 0x47, 0x0a, 0x0e, + 0x43, 0x6f, 0x64, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, + 0x0a, 0x0e, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x5f, 0x46, 0x4f, 0x52, 0x4d, 0x41, 0x54, + 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x4e, 0x4f, 0x52, 0x4d, 0x41, 0x4c, 0x10, 0x01, 0x12, 0x0a, + 0x0a, 0x06, 0x50, 0x52, 0x45, 0x46, 0x49, 0x58, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x45, 0x4d, + 0x4f, 0x4a, 0x49, 0x10, 0x03, 0x2a, 0x3f, 0x0a, 0x0c, 0x4c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, + 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x10, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, + 0x5f, 0x4c, 0x41, 0x4e, 0x47, 0x55, 0x41, 0x47, 0x45, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x45, + 0x4e, 0x47, 0x4c, 0x49, 0x53, 0x48, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x4a, 0x41, 0x50, 0x41, + 0x4e, 0x45, 0x53, 0x45, 0x10, 0x02, 0x42, 0x0b, 0x5a, 0x09, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, + 0x73, 0x72, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_code_type_proto_rawDescOnce sync.Once + file_code_type_proto_rawDescData = file_code_type_proto_rawDesc +) + +func file_code_type_proto_rawDescGZIP() []byte { + file_code_type_proto_rawDescOnce.Do(func() { + file_code_type_proto_rawDescData = protoimpl.X.CompressGZIP(file_code_type_proto_rawDescData) + }) + return file_code_type_proto_rawDescData +} + +var file_code_type_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_code_type_proto_goTypes = []interface{}{ + (CodeFormatType)(0), // 0: code_type.CodeFormatType + (LanguageType)(0), // 1: code_type.LanguageType +} +var file_code_type_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_code_type_proto_init() } +func file_code_type_proto_init() { + if File_code_type_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_code_type_proto_rawDesc, + NumEnums: 2, + NumMessages: 0, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_code_type_proto_goTypes, + DependencyIndexes: file_code_type_proto_depIdxs, + EnumInfos: file_code_type_proto_enumTypes, + }.Build() + File_code_type_proto = out.File + file_code_type_proto_rawDesc = nil + file_code_type_proto_goTypes = nil + file_code_type_proto_depIdxs = nil +} diff --git a/pkg/grpc/commit_message_service.pb.go b/proto/gen/commit_message_service.pb.go similarity index 51% rename from pkg/grpc/commit_message_service.pb.go rename to proto/gen/commit_message_service.pb.go index fe6d734..a82a577 100644 --- a/pkg/grpc/commit_message_service.pb.go +++ b/proto/gen/commit_message_service.pb.go @@ -1,10 +1,10 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.31.0 -// protoc v4.24.2 +// protoc v4.24.4 // source: commit_message_service.proto -package pb +package src import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" @@ -20,103 +20,6 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -// CodeFormatType specifies the type of commit message to generate -type CodeFormatType int32 - -const ( - CodeFormatType_EMOJI CodeFormatType = 0 - CodeFormatType_PREFIX CodeFormatType = 1 - CodeFormatType_NORMAL CodeFormatType = 2 -) - -// Enum value maps for CodeFormatType. -var ( - CodeFormatType_name = map[int32]string{ - 0: "EMOJI", - 1: "PREFIX", - 2: "NORMAL", - } - CodeFormatType_value = map[string]int32{ - "EMOJI": 0, - "PREFIX": 1, - "NORMAL": 2, - } -) - -func (x CodeFormatType) Enum() *CodeFormatType { - p := new(CodeFormatType) - *p = x - return p -} - -func (x CodeFormatType) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (CodeFormatType) Descriptor() protoreflect.EnumDescriptor { - return file_commit_message_service_proto_enumTypes[0].Descriptor() -} - -func (CodeFormatType) Type() protoreflect.EnumType { - return &file_commit_message_service_proto_enumTypes[0] -} - -func (x CodeFormatType) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use CodeFormatType.Descriptor instead. -func (CodeFormatType) EnumDescriptor() ([]byte, []int) { - return file_commit_message_service_proto_rawDescGZIP(), []int{0} -} - -// LanguageType specifies the language of the commit message to generate -type LanguageType int32 - -const ( - LanguageType_ENGLISH LanguageType = 0 - LanguageType_JAPANESE LanguageType = 1 -) - -// Enum value maps for LanguageType. -var ( - LanguageType_name = map[int32]string{ - 0: "ENGLISH", - 1: "JAPANESE", - } - LanguageType_value = map[string]int32{ - "ENGLISH": 0, - "JAPANESE": 1, - } -) - -func (x LanguageType) Enum() *LanguageType { - p := new(LanguageType) - *p = x - return p -} - -func (x LanguageType) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (LanguageType) Descriptor() protoreflect.EnumDescriptor { - return file_commit_message_service_proto_enumTypes[1].Descriptor() -} - -func (LanguageType) Type() protoreflect.EnumType { - return &file_commit_message_service_proto_enumTypes[1] -} - -func (x LanguageType) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use LanguageType.Descriptor instead. -func (LanguageType) EnumDescriptor() ([]byte, []int) { - return file_commit_message_service_proto_rawDescGZIP(), []int{1} -} - // CommitMessageRequest is the request format for generating messages type CommitMessageRequest struct { state protoimpl.MessageState @@ -124,8 +27,8 @@ type CommitMessageRequest struct { unknownFields protoimpl.UnknownFields InputCode string `protobuf:"bytes,1,opt,name=inputCode,proto3" json:"inputCode,omitempty"` - CodeFormat CodeFormatType `protobuf:"varint,2,opt,name=codeFormat,proto3,enum=commit_message.CodeFormatType" json:"codeFormat,omitempty"` - Language LanguageType `protobuf:"varint,3,opt,name=language,proto3,enum=commit_message.LanguageType" json:"language,omitempty"` + CodeFormat CodeFormatType `protobuf:"varint,2,opt,name=codeFormat,proto3,enum=code_type.CodeFormatType" json:"codeFormat,omitempty"` + Language LanguageType `protobuf:"varint,3,opt,name=language,proto3,enum=code_type.LanguageType" json:"language,omitempty"` } func (x *CommitMessageRequest) Reset() { @@ -171,14 +74,14 @@ func (x *CommitMessageRequest) GetCodeFormat() CodeFormatType { if x != nil { return x.CodeFormat } - return CodeFormatType_EMOJI + return CodeFormatType_UNKNOWN_FORMAT } func (x *CommitMessageRequest) GetLanguage() LanguageType { if x != nil { return x.Language } - return LanguageType_ENGLISH + return LanguageType_UNKNOWN_LANGUAGE } // CommitMessageResponse returns generated commit messages @@ -234,37 +137,31 @@ var File_commit_message_service_proto protoreflect.FileDescriptor var file_commit_message_service_proto_rawDesc = []byte{ 0x0a, 0x1c, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0e, - 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0xae, - 0x01, 0x0a, 0x14, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x70, 0x75, 0x74, - 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x69, 0x6e, 0x70, 0x75, - 0x74, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x3e, 0x0a, 0x0a, 0x63, 0x6f, 0x64, 0x65, 0x46, 0x6f, 0x72, - 0x6d, 0x61, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, - 0x69, 0x74, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x43, 0x6f, 0x64, 0x65, 0x46, - 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x0a, 0x63, 0x6f, 0x64, 0x65, 0x46, - 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x12, 0x38, 0x0a, 0x08, 0x6c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, - 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1c, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, - 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x4c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, - 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x08, 0x6c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x22, - 0x33, 0x0a, 0x15, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x65, 0x73, 0x73, - 0x61, 0x67, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x6d, 0x65, 0x73, 0x73, - 0x61, 0x67, 0x65, 0x73, 0x2a, 0x33, 0x0a, 0x0e, 0x43, 0x6f, 0x64, 0x65, 0x46, 0x6f, 0x72, 0x6d, - 0x61, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x09, 0x0a, 0x05, 0x45, 0x4d, 0x4f, 0x4a, 0x49, 0x10, - 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x50, 0x52, 0x45, 0x46, 0x49, 0x58, 0x10, 0x01, 0x12, 0x0a, 0x0a, - 0x06, 0x4e, 0x4f, 0x52, 0x4d, 0x41, 0x4c, 0x10, 0x02, 0x2a, 0x29, 0x0a, 0x0c, 0x4c, 0x61, 0x6e, - 0x67, 0x75, 0x61, 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x45, 0x4e, 0x47, - 0x4c, 0x49, 0x53, 0x48, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x4a, 0x41, 0x50, 0x41, 0x4e, 0x45, - 0x53, 0x45, 0x10, 0x01, 0x32, 0x7c, 0x0a, 0x14, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x4d, 0x65, - 0x73, 0x73, 0x61, 0x67, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x64, 0x0a, 0x15, - 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x4d, 0x65, - 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x24, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x5f, 0x6d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x4d, 0x65, 0x73, - 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x63, 0x6f, - 0x6d, 0x6d, 0x69, 0x74, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x43, 0x6f, 0x6d, - 0x6d, 0x69, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x42, 0x08, 0x5a, 0x06, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x0f, + 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, + 0xa4, 0x01, 0x0a, 0x14, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x70, 0x75, + 0x74, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x69, 0x6e, 0x70, + 0x75, 0x74, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x39, 0x0a, 0x0a, 0x63, 0x6f, 0x64, 0x65, 0x46, 0x6f, + 0x72, 0x6d, 0x61, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x64, + 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x43, 0x6f, 0x64, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, + 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x0a, 0x63, 0x6f, 0x64, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, + 0x74, 0x12, 0x33, 0x0a, 0x08, 0x6c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x0e, 0x32, 0x17, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x2e, + 0x4c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x08, 0x6c, 0x61, + 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x22, 0x33, 0x0a, 0x15, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, + 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x1a, 0x0a, 0x08, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, + 0x09, 0x52, 0x08, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x32, 0x7c, 0x0a, 0x14, 0x43, + 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x53, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x12, 0x64, 0x0a, 0x15, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x43, + 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x24, 0x2e, 0x63, + 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x43, 0x6f, + 0x6d, 0x6d, 0x69, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x5f, 0x6d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x0b, 0x5a, 0x09, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2f, 0x73, 0x72, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -279,19 +176,18 @@ func file_commit_message_service_proto_rawDescGZIP() []byte { return file_commit_message_service_proto_rawDescData } -var file_commit_message_service_proto_enumTypes = make([]protoimpl.EnumInfo, 2) var file_commit_message_service_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_commit_message_service_proto_goTypes = []interface{}{ - (CodeFormatType)(0), // 0: commit_message.CodeFormatType - (LanguageType)(0), // 1: commit_message.LanguageType - (*CommitMessageRequest)(nil), // 2: commit_message.CommitMessageRequest - (*CommitMessageResponse)(nil), // 3: commit_message.CommitMessageResponse + (*CommitMessageRequest)(nil), // 0: commit_message.CommitMessageRequest + (*CommitMessageResponse)(nil), // 1: commit_message.CommitMessageResponse + (CodeFormatType)(0), // 2: code_type.CodeFormatType + (LanguageType)(0), // 3: code_type.LanguageType } var file_commit_message_service_proto_depIdxs = []int32{ - 0, // 0: commit_message.CommitMessageRequest.codeFormat:type_name -> commit_message.CodeFormatType - 1, // 1: commit_message.CommitMessageRequest.language:type_name -> commit_message.LanguageType - 2, // 2: commit_message.CommitMessageService.GenerateCommitMessage:input_type -> commit_message.CommitMessageRequest - 3, // 3: commit_message.CommitMessageService.GenerateCommitMessage:output_type -> commit_message.CommitMessageResponse + 2, // 0: commit_message.CommitMessageRequest.codeFormat:type_name -> code_type.CodeFormatType + 3, // 1: commit_message.CommitMessageRequest.language:type_name -> code_type.LanguageType + 0, // 2: commit_message.CommitMessageService.GenerateCommitMessage:input_type -> commit_message.CommitMessageRequest + 1, // 3: commit_message.CommitMessageService.GenerateCommitMessage:output_type -> commit_message.CommitMessageResponse 3, // [3:4] is the sub-list for method output_type 2, // [2:3] is the sub-list for method input_type 2, // [2:2] is the sub-list for extension type_name @@ -304,6 +200,7 @@ func file_commit_message_service_proto_init() { if File_commit_message_service_proto != nil { return } + file_code_type_proto_init() if !protoimpl.UnsafeEnabled { file_commit_message_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*CommitMessageRequest); i { @@ -335,14 +232,13 @@ func file_commit_message_service_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_commit_message_service_proto_rawDesc, - NumEnums: 2, + NumEnums: 0, NumMessages: 2, NumExtensions: 0, NumServices: 1, }, GoTypes: file_commit_message_service_proto_goTypes, DependencyIndexes: file_commit_message_service_proto_depIdxs, - EnumInfos: file_commit_message_service_proto_enumTypes, MessageInfos: file_commit_message_service_proto_msgTypes, }.Build() File_commit_message_service_proto = out.File diff --git a/pkg/grpc/commit_message_service_grpc.pb.go b/proto/gen/commit_message_service_grpc.pb.go similarity index 98% rename from pkg/grpc/commit_message_service_grpc.pb.go rename to proto/gen/commit_message_service_grpc.pb.go index 65a91f3..3bd3153 100644 --- a/pkg/grpc/commit_message_service_grpc.pb.go +++ b/proto/gen/commit_message_service_grpc.pb.go @@ -1,10 +1,10 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.3.0 -// - protoc v4.24.2 +// - protoc v4.24.4 // source: commit_message_service.proto -package pb +package src import ( context "context" diff --git a/proto/gen/separate_commit_service.pb.go b/proto/gen/separate_commit_service.pb.go new file mode 100644 index 0000000..96c736a --- /dev/null +++ b/proto/gen/separate_commit_service.pb.go @@ -0,0 +1,640 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v4.24.4 +// source: separate_commit_service.proto + +package src + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// ChangeType specifies the type of +type ChangeType int32 + +const ( + ChangeType_UNKNOWN_CHANGE ChangeType = 0 + ChangeType_CREATE ChangeType = 1 + ChangeType_UPDATE ChangeType = 2 + ChangeType_DELETE ChangeType = 3 +) + +// Enum value maps for ChangeType. +var ( + ChangeType_name = map[int32]string{ + 0: "UNKNOWN_CHANGE", + 1: "CREATE", + 2: "UPDATE", + 3: "DELETE", + } + ChangeType_value = map[string]int32{ + "UNKNOWN_CHANGE": 0, + "CREATE": 1, + "UPDATE": 2, + "DELETE": 3, + } +) + +func (x ChangeType) Enum() *ChangeType { + p := new(ChangeType) + *p = x + return p +} + +func (x ChangeType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (ChangeType) Descriptor() protoreflect.EnumDescriptor { + return file_separate_commit_service_proto_enumTypes[0].Descriptor() +} + +func (ChangeType) Type() protoreflect.EnumType { + return &file_separate_commit_service_proto_enumTypes[0] +} + +func (x ChangeType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use ChangeType.Descriptor instead. +func (ChangeType) EnumDescriptor() ([]byte, []int) { + return file_separate_commit_service_proto_rawDescGZIP(), []int{0} +} + +// SeparateCommitRequest is the request format for generating messages +type SeparateCommitRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + FileChanges []*FileChange `protobuf:"bytes,1,rep,name=fileChanges,proto3" json:"fileChanges,omitempty"` + CodeFormat CodeFormatType `protobuf:"varint,2,opt,name=codeFormat,proto3,enum=code_type.CodeFormatType" json:"codeFormat,omitempty"` + Language LanguageType `protobuf:"varint,3,opt,name=language,proto3,enum=code_type.LanguageType" json:"language,omitempty"` +} + +func (x *SeparateCommitRequest) Reset() { + *x = SeparateCommitRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_separate_commit_service_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SeparateCommitRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SeparateCommitRequest) ProtoMessage() {} + +func (x *SeparateCommitRequest) ProtoReflect() protoreflect.Message { + mi := &file_separate_commit_service_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SeparateCommitRequest.ProtoReflect.Descriptor instead. +func (*SeparateCommitRequest) Descriptor() ([]byte, []int) { + return file_separate_commit_service_proto_rawDescGZIP(), []int{0} +} + +func (x *SeparateCommitRequest) GetFileChanges() []*FileChange { + if x != nil { + return x.FileChanges + } + return nil +} + +func (x *SeparateCommitRequest) GetCodeFormat() CodeFormatType { + if x != nil { + return x.CodeFormat + } + return CodeFormatType_UNKNOWN_FORMAT +} + +func (x *SeparateCommitRequest) GetLanguage() LanguageType { + if x != nil { + return x.Language + } + return LanguageType_UNKNOWN_LANGUAGE +} + +type LineDiff struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Index int32 `protobuf:"varint,1,opt,name=index,proto3" json:"index,omitempty"` + Line string `protobuf:"bytes,2,opt,name=line,proto3" json:"line,omitempty"` +} + +func (x *LineDiff) Reset() { + *x = LineDiff{} + if protoimpl.UnsafeEnabled { + mi := &file_separate_commit_service_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LineDiff) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LineDiff) ProtoMessage() {} + +func (x *LineDiff) ProtoReflect() protoreflect.Message { + mi := &file_separate_commit_service_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LineDiff.ProtoReflect.Descriptor instead. +func (*LineDiff) Descriptor() ([]byte, []int) { + return file_separate_commit_service_proto_rawDescGZIP(), []int{1} +} + +func (x *LineDiff) GetIndex() int32 { + if x != nil { + return x.Index + } + return 0 +} + +func (x *LineDiff) GetLine() string { + if x != nil { + return x.Line + } + return "" +} + +type CodeDiff struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Added []*LineDiff `protobuf:"bytes,1,rep,name=added,proto3" json:"added,omitempty"` + Deleted []*LineDiff `protobuf:"bytes,2,rep,name=deleted,proto3" json:"deleted,omitempty"` +} + +func (x *CodeDiff) Reset() { + *x = CodeDiff{} + if protoimpl.UnsafeEnabled { + mi := &file_separate_commit_service_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CodeDiff) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CodeDiff) ProtoMessage() {} + +func (x *CodeDiff) ProtoReflect() protoreflect.Message { + mi := &file_separate_commit_service_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CodeDiff.ProtoReflect.Descriptor instead. +func (*CodeDiff) Descriptor() ([]byte, []int) { + return file_separate_commit_service_proto_rawDescGZIP(), []int{2} +} + +func (x *CodeDiff) GetAdded() []*LineDiff { + if x != nil { + return x.Added + } + return nil +} + +func (x *CodeDiff) GetDeleted() []*LineDiff { + if x != nil { + return x.Deleted + } + return nil +} + +type FileChange struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + CodeDiff *CodeDiff `protobuf:"bytes,1,opt,name=codeDiff,proto3" json:"codeDiff,omitempty"` + Filename string `protobuf:"bytes,2,opt,name=filename,proto3" json:"filename,omitempty"` + ChangeType ChangeType `protobuf:"varint,3,opt,name=changeType,proto3,enum=separate_commit.ChangeType" json:"changeType,omitempty"` +} + +func (x *FileChange) Reset() { + *x = FileChange{} + if protoimpl.UnsafeEnabled { + mi := &file_separate_commit_service_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FileChange) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FileChange) ProtoMessage() {} + +func (x *FileChange) ProtoReflect() protoreflect.Message { + mi := &file_separate_commit_service_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FileChange.ProtoReflect.Descriptor instead. +func (*FileChange) Descriptor() ([]byte, []int) { + return file_separate_commit_service_proto_rawDescGZIP(), []int{3} +} + +func (x *FileChange) GetCodeDiff() *CodeDiff { + if x != nil { + return x.CodeDiff + } + return nil +} + +func (x *FileChange) GetFilename() string { + if x != nil { + return x.Filename + } + return "" +} + +func (x *FileChange) GetChangeType() ChangeType { + if x != nil { + return x.ChangeType + } + return ChangeType_UNKNOWN_CHANGE +} + +// SeparateCommitResponse returns generated and separated commit messages +type SeparateCommitResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + SeparatedCommits []*SeparatedCommitMessages `protobuf:"bytes,1,rep,name=separatedCommits,proto3" json:"separatedCommits,omitempty"` +} + +func (x *SeparateCommitResponse) Reset() { + *x = SeparateCommitResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_separate_commit_service_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SeparateCommitResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SeparateCommitResponse) ProtoMessage() {} + +func (x *SeparateCommitResponse) ProtoReflect() protoreflect.Message { + mi := &file_separate_commit_service_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SeparateCommitResponse.ProtoReflect.Descriptor instead. +func (*SeparateCommitResponse) Descriptor() ([]byte, []int) { + return file_separate_commit_service_proto_rawDescGZIP(), []int{4} +} + +func (x *SeparateCommitResponse) GetSeparatedCommits() []*SeparatedCommitMessages { + if x != nil { + return x.SeparatedCommits + } + return nil +} + +type SeparatedCommitMessages struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Messages []string `protobuf:"bytes,1,rep,name=messages,proto3" json:"messages,omitempty"` + Filename string `protobuf:"bytes,2,opt,name=filename,proto3" json:"filename,omitempty"` + ChangeType ChangeType `protobuf:"varint,3,opt,name=changeType,proto3,enum=separate_commit.ChangeType" json:"changeType,omitempty"` +} + +func (x *SeparatedCommitMessages) Reset() { + *x = SeparatedCommitMessages{} + if protoimpl.UnsafeEnabled { + mi := &file_separate_commit_service_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SeparatedCommitMessages) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SeparatedCommitMessages) ProtoMessage() {} + +func (x *SeparatedCommitMessages) ProtoReflect() protoreflect.Message { + mi := &file_separate_commit_service_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SeparatedCommitMessages.ProtoReflect.Descriptor instead. +func (*SeparatedCommitMessages) Descriptor() ([]byte, []int) { + return file_separate_commit_service_proto_rawDescGZIP(), []int{5} +} + +func (x *SeparatedCommitMessages) GetMessages() []string { + if x != nil { + return x.Messages + } + return nil +} + +func (x *SeparatedCommitMessages) GetFilename() string { + if x != nil { + return x.Filename + } + return "" +} + +func (x *SeparatedCommitMessages) GetChangeType() ChangeType { + if x != nil { + return x.ChangeType + } + return ChangeType_UNKNOWN_CHANGE +} + +var File_separate_commit_service_proto protoreflect.FileDescriptor + +var file_separate_commit_service_proto_rawDesc = []byte{ + 0x0a, 0x1d, 0x73, 0x65, 0x70, 0x61, 0x72, 0x61, 0x74, 0x65, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, + 0x74, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, + 0x0f, 0x73, 0x65, 0x70, 0x61, 0x72, 0x61, 0x74, 0x65, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, + 0x1a, 0x0f, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x22, 0xc6, 0x01, 0x0a, 0x15, 0x53, 0x65, 0x70, 0x61, 0x72, 0x61, 0x74, 0x65, 0x43, 0x6f, + 0x6d, 0x6d, 0x69, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x3d, 0x0a, 0x0b, 0x66, + 0x69, 0x6c, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x1b, 0x2e, 0x73, 0x65, 0x70, 0x61, 0x72, 0x61, 0x74, 0x65, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, + 0x69, 0x74, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x0b, 0x66, + 0x69, 0x6c, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x12, 0x39, 0x0a, 0x0a, 0x63, 0x6f, + 0x64, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x19, + 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x43, 0x6f, 0x64, 0x65, 0x46, + 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x0a, 0x63, 0x6f, 0x64, 0x65, 0x46, + 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x12, 0x33, 0x0a, 0x08, 0x6c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, + 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x17, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x74, + 0x79, 0x70, 0x65, 0x2e, 0x4c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, + 0x52, 0x08, 0x6c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x22, 0x34, 0x0a, 0x08, 0x4c, 0x69, + 0x6e, 0x65, 0x44, 0x69, 0x66, 0x66, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x12, 0x0a, 0x04, + 0x6c, 0x69, 0x6e, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6c, 0x69, 0x6e, 0x65, + 0x22, 0x70, 0x0a, 0x08, 0x43, 0x6f, 0x64, 0x65, 0x44, 0x69, 0x66, 0x66, 0x12, 0x2f, 0x0a, 0x05, + 0x61, 0x64, 0x64, 0x65, 0x64, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x73, 0x65, + 0x70, 0x61, 0x72, 0x61, 0x74, 0x65, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x2e, 0x4c, 0x69, + 0x6e, 0x65, 0x44, 0x69, 0x66, 0x66, 0x52, 0x05, 0x61, 0x64, 0x64, 0x65, 0x64, 0x12, 0x33, 0x0a, + 0x07, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, + 0x2e, 0x73, 0x65, 0x70, 0x61, 0x72, 0x61, 0x74, 0x65, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, + 0x2e, 0x4c, 0x69, 0x6e, 0x65, 0x44, 0x69, 0x66, 0x66, 0x52, 0x07, 0x64, 0x65, 0x6c, 0x65, 0x74, + 0x65, 0x64, 0x22, 0x9c, 0x01, 0x0a, 0x0a, 0x46, 0x69, 0x6c, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, + 0x65, 0x12, 0x35, 0x0a, 0x08, 0x63, 0x6f, 0x64, 0x65, 0x44, 0x69, 0x66, 0x66, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x73, 0x65, 0x70, 0x61, 0x72, 0x61, 0x74, 0x65, 0x5f, 0x63, + 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x2e, 0x43, 0x6f, 0x64, 0x65, 0x44, 0x69, 0x66, 0x66, 0x52, 0x08, + 0x63, 0x6f, 0x64, 0x65, 0x44, 0x69, 0x66, 0x66, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69, 0x6c, 0x65, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, + 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x3b, 0x0a, 0x0a, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x54, 0x79, + 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1b, 0x2e, 0x73, 0x65, 0x70, 0x61, 0x72, + 0x61, 0x74, 0x65, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x2e, 0x43, 0x68, 0x61, 0x6e, 0x67, + 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x0a, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x54, 0x79, 0x70, + 0x65, 0x22, 0x6e, 0x0a, 0x16, 0x53, 0x65, 0x70, 0x61, 0x72, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6d, + 0x6d, 0x69, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x54, 0x0a, 0x10, 0x73, + 0x65, 0x70, 0x61, 0x72, 0x61, 0x74, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x73, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x73, 0x65, 0x70, 0x61, 0x72, 0x61, 0x74, 0x65, + 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x2e, 0x53, 0x65, 0x70, 0x61, 0x72, 0x61, 0x74, 0x65, + 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x52, + 0x10, 0x73, 0x65, 0x70, 0x61, 0x72, 0x61, 0x74, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, + 0x73, 0x22, 0x8e, 0x01, 0x0a, 0x17, 0x53, 0x65, 0x70, 0x61, 0x72, 0x61, 0x74, 0x65, 0x64, 0x43, + 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x12, 0x1a, 0x0a, + 0x08, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, + 0x08, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69, 0x6c, + 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x69, 0x6c, + 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x3b, 0x0a, 0x0a, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x54, + 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1b, 0x2e, 0x73, 0x65, 0x70, 0x61, + 0x72, 0x61, 0x74, 0x65, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x2e, 0x43, 0x68, 0x61, 0x6e, + 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x0a, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x54, 0x79, + 0x70, 0x65, 0x2a, 0x44, 0x0a, 0x0a, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, + 0x12, 0x12, 0x0a, 0x0e, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x5f, 0x43, 0x48, 0x41, 0x4e, + 0x47, 0x45, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x43, 0x52, 0x45, 0x41, 0x54, 0x45, 0x10, 0x01, + 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, + 0x44, 0x45, 0x4c, 0x45, 0x54, 0x45, 0x10, 0x03, 0x32, 0x89, 0x01, 0x0a, 0x15, 0x53, 0x65, 0x70, + 0x61, 0x72, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x12, 0x70, 0x0a, 0x1d, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x4d, 0x75, + 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x4d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x12, 0x26, 0x2e, 0x73, 0x65, 0x70, 0x61, 0x72, 0x61, 0x74, 0x65, 0x5f, 0x63, + 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x2e, 0x53, 0x65, 0x70, 0x61, 0x72, 0x61, 0x74, 0x65, 0x43, 0x6f, + 0x6d, 0x6d, 0x69, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x73, 0x65, + 0x70, 0x61, 0x72, 0x61, 0x74, 0x65, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x2e, 0x53, 0x65, + 0x70, 0x61, 0x72, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x0b, 0x5a, 0x09, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x72, + 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_separate_commit_service_proto_rawDescOnce sync.Once + file_separate_commit_service_proto_rawDescData = file_separate_commit_service_proto_rawDesc +) + +func file_separate_commit_service_proto_rawDescGZIP() []byte { + file_separate_commit_service_proto_rawDescOnce.Do(func() { + file_separate_commit_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_separate_commit_service_proto_rawDescData) + }) + return file_separate_commit_service_proto_rawDescData +} + +var file_separate_commit_service_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_separate_commit_service_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_separate_commit_service_proto_goTypes = []interface{}{ + (ChangeType)(0), // 0: separate_commit.ChangeType + (*SeparateCommitRequest)(nil), // 1: separate_commit.SeparateCommitRequest + (*LineDiff)(nil), // 2: separate_commit.LineDiff + (*CodeDiff)(nil), // 3: separate_commit.CodeDiff + (*FileChange)(nil), // 4: separate_commit.FileChange + (*SeparateCommitResponse)(nil), // 5: separate_commit.SeparateCommitResponse + (*SeparatedCommitMessages)(nil), // 6: separate_commit.SeparatedCommitMessages + (CodeFormatType)(0), // 7: code_type.CodeFormatType + (LanguageType)(0), // 8: code_type.LanguageType +} +var file_separate_commit_service_proto_depIdxs = []int32{ + 4, // 0: separate_commit.SeparateCommitRequest.fileChanges:type_name -> separate_commit.FileChange + 7, // 1: separate_commit.SeparateCommitRequest.codeFormat:type_name -> code_type.CodeFormatType + 8, // 2: separate_commit.SeparateCommitRequest.language:type_name -> code_type.LanguageType + 2, // 3: separate_commit.CodeDiff.added:type_name -> separate_commit.LineDiff + 2, // 4: separate_commit.CodeDiff.deleted:type_name -> separate_commit.LineDiff + 3, // 5: separate_commit.FileChange.codeDiff:type_name -> separate_commit.CodeDiff + 0, // 6: separate_commit.FileChange.changeType:type_name -> separate_commit.ChangeType + 6, // 7: separate_commit.SeparateCommitResponse.separatedCommits:type_name -> separate_commit.SeparatedCommitMessages + 0, // 8: separate_commit.SeparatedCommitMessages.changeType:type_name -> separate_commit.ChangeType + 1, // 9: separate_commit.SeparateCommitService.GenerateMultipleCommitMessage:input_type -> separate_commit.SeparateCommitRequest + 5, // 10: separate_commit.SeparateCommitService.GenerateMultipleCommitMessage:output_type -> separate_commit.SeparateCommitResponse + 10, // [10:11] is the sub-list for method output_type + 9, // [9:10] is the sub-list for method input_type + 9, // [9:9] is the sub-list for extension type_name + 9, // [9:9] is the sub-list for extension extendee + 0, // [0:9] is the sub-list for field type_name +} + +func init() { file_separate_commit_service_proto_init() } +func file_separate_commit_service_proto_init() { + if File_separate_commit_service_proto != nil { + return + } + file_code_type_proto_init() + if !protoimpl.UnsafeEnabled { + file_separate_commit_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SeparateCommitRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_separate_commit_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LineDiff); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_separate_commit_service_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CodeDiff); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_separate_commit_service_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FileChange); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_separate_commit_service_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SeparateCommitResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_separate_commit_service_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SeparatedCommitMessages); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_separate_commit_service_proto_rawDesc, + NumEnums: 1, + NumMessages: 6, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_separate_commit_service_proto_goTypes, + DependencyIndexes: file_separate_commit_service_proto_depIdxs, + EnumInfos: file_separate_commit_service_proto_enumTypes, + MessageInfos: file_separate_commit_service_proto_msgTypes, + }.Build() + File_separate_commit_service_proto = out.File + file_separate_commit_service_proto_rawDesc = nil + file_separate_commit_service_proto_goTypes = nil + file_separate_commit_service_proto_depIdxs = nil +} diff --git a/proto/gen/separate_commit_service_grpc.pb.go b/proto/gen/separate_commit_service_grpc.pb.go new file mode 100644 index 0000000..3fc3840 --- /dev/null +++ b/proto/gen/separate_commit_service_grpc.pb.go @@ -0,0 +1,109 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc v4.24.4 +// source: separate_commit_service.proto + +package src + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +const ( + SeparateCommitService_GenerateMultipleCommitMessage_FullMethodName = "/separate_commit.SeparateCommitService/GenerateMultipleCommitMessage" +) + +// SeparateCommitServiceClient is the client API for SeparateCommitService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type SeparateCommitServiceClient interface { + GenerateMultipleCommitMessage(ctx context.Context, in *SeparateCommitRequest, opts ...grpc.CallOption) (*SeparateCommitResponse, error) +} + +type separateCommitServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewSeparateCommitServiceClient(cc grpc.ClientConnInterface) SeparateCommitServiceClient { + return &separateCommitServiceClient{cc} +} + +func (c *separateCommitServiceClient) GenerateMultipleCommitMessage(ctx context.Context, in *SeparateCommitRequest, opts ...grpc.CallOption) (*SeparateCommitResponse, error) { + out := new(SeparateCommitResponse) + err := c.cc.Invoke(ctx, SeparateCommitService_GenerateMultipleCommitMessage_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// SeparateCommitServiceServer is the server API for SeparateCommitService service. +// All implementations must embed UnimplementedSeparateCommitServiceServer +// for forward compatibility +type SeparateCommitServiceServer interface { + GenerateMultipleCommitMessage(context.Context, *SeparateCommitRequest) (*SeparateCommitResponse, error) + mustEmbedUnimplementedSeparateCommitServiceServer() +} + +// UnimplementedSeparateCommitServiceServer must be embedded to have forward compatible implementations. +type UnimplementedSeparateCommitServiceServer struct { +} + +func (UnimplementedSeparateCommitServiceServer) GenerateMultipleCommitMessage(context.Context, *SeparateCommitRequest) (*SeparateCommitResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GenerateMultipleCommitMessage not implemented") +} +func (UnimplementedSeparateCommitServiceServer) mustEmbedUnimplementedSeparateCommitServiceServer() {} + +// UnsafeSeparateCommitServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to SeparateCommitServiceServer will +// result in compilation errors. +type UnsafeSeparateCommitServiceServer interface { + mustEmbedUnimplementedSeparateCommitServiceServer() +} + +func RegisterSeparateCommitServiceServer(s grpc.ServiceRegistrar, srv SeparateCommitServiceServer) { + s.RegisterService(&SeparateCommitService_ServiceDesc, srv) +} + +func _SeparateCommitService_GenerateMultipleCommitMessage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SeparateCommitRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SeparateCommitServiceServer).GenerateMultipleCommitMessage(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: SeparateCommitService_GenerateMultipleCommitMessage_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SeparateCommitServiceServer).GenerateMultipleCommitMessage(ctx, req.(*SeparateCommitRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// SeparateCommitService_ServiceDesc is the grpc.ServiceDesc for SeparateCommitService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var SeparateCommitService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "separate_commit.SeparateCommitService", + HandlerType: (*SeparateCommitServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GenerateMultipleCommitMessage", + Handler: _SeparateCommitService_GenerateMultipleCommitMessage_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "separate_commit_service.proto", +} diff --git a/proto/src/code_type.proto b/proto/src/code_type.proto new file mode 100644 index 0000000..c7c5b42 --- /dev/null +++ b/proto/src/code_type.proto @@ -0,0 +1,21 @@ +syntax = "proto3"; + +option go_package = "proto/src"; + +package code_type; + + +// CodeFormatType specifies the type of commit message to generate +enum CodeFormatType { + UNKNOWN_FORMAT = 0; + NORMAL = 1; + PREFIX = 2; + EMOJI = 3; +} + +// LanguageType specifies the language of the commit message to generate +enum LanguageType { + UNKNOWN_LANGUAGE = 0; + ENGLISH =1; + JAPANESE =2; +} \ No newline at end of file diff --git a/proto/src/commit_message_service.proto b/proto/src/commit_message_service.proto new file mode 100644 index 0000000..f9bcd93 --- /dev/null +++ b/proto/src/commit_message_service.proto @@ -0,0 +1,24 @@ +syntax = "proto3"; + +option go_package = "proto/src"; + +package commit_message; + +import "code_type.proto"; + +// CommitMessageService provides methods to generate commit messages +service CommitMessageService { + rpc GenerateCommitMessage(CommitMessageRequest) returns (CommitMessageResponse); +} + +// CommitMessageRequest is the request format for generating messages +message CommitMessageRequest { + string inputCode = 1; + code_type.CodeFormatType codeFormat = 2; + code_type.LanguageType language = 3; +} + +// CommitMessageResponse returns generated commit messages +message CommitMessageResponse { + repeated string messages = 1; +} \ No newline at end of file diff --git a/proto/src/separate_commit_service.proto b/proto/src/separate_commit_service.proto new file mode 100644 index 0000000..26b9f8a --- /dev/null +++ b/proto/src/separate_commit_service.proto @@ -0,0 +1,53 @@ +syntax = "proto3"; + +option go_package = "proto/src"; + +package separate_commit; + +import "code_type.proto"; + +service SeparateCommitService { + rpc GenerateMultipleCommitMessage(SeparateCommitRequest) returns (SeparateCommitResponse); +} + +// SeparateCommitRequest is the request format for generating messages +message SeparateCommitRequest { + repeated FileChange fileChanges = 1; + code_type.CodeFormatType codeFormat = 2; + code_type.LanguageType language = 3; +} + +message LineDiff { + int32 index = 1; + string line = 2; +} + +message CodeDiff { + repeated LineDiff added = 1; + repeated LineDiff deleted = 2; +} + +message FileChange { + CodeDiff codeDiff = 1; + string filename = 2; + ChangeType changeType = 3; +} + +// ChangeType specifies the type of +enum ChangeType { + UNKNOWN_CHANGE = 0; + CREATE = 1; + UPDATE = 2; + DELETE = 3; +} + +// SeparateCommitResponse returns generated and separated commit messages +message SeparateCommitResponse { + repeated SeparatedCommitMessages separatedCommits = 1; +} + +message SeparatedCommitMessages { + repeated string messages = 1; + string filename = 2; + ChangeType changeType = 3; +}