diff --git a/identify.go b/identify.go new file mode 100644 index 0000000..c84f385 --- /dev/null +++ b/identify.go @@ -0,0 +1,17 @@ +package forgepb + +import ( + "go.wit.com/log" +) + +// print the protobuf in human form +func IdentifyProtobuf(data []byte) error { + var pb *Identify + pb = new(Identify) + if err := pb.Unmarshal(data); err != nil { + log.Info("data can't be identified as a standard protobuf. len =", len(data)) + return err + } + log.Info("Identify protobuf file uuid =", pb.Uuid, "version =", pb.Version) + return nil +} diff --git a/patchset.proto b/patchset.proto index 6f43da7..c4f99c6 100644 --- a/patchset.proto +++ b/patchset.proto @@ -4,6 +4,13 @@ package forgepb; import "google/protobuf/timestamp.proto"; // Import the well-known type for Timestamp +// this generic message is used by autogen to identify and +// then dump the uuid and version from any arbitrary .pb file +message Identify { // `autogenpb:marshal` + string uuid = 1; // + string version = 2; // +} + message Patch { string filename = 1; // `autogenpb:unique` `autogenpb:sort` bytes data = 2; //