使用中繼資料檔案定義 Fuchsia 套件資訊

說明

Fuchsia 的 Gerrit 安裝程序支援自訂結構化中繼資料檔案。這類檔案的設計目的如下:

  • 「人類可讀」並提供實用資訊,例如套件的名稱、說明和標準網址
  • 以標準格式定義檔案,機器可讀取,以便自動化系統用於執行各種作業,例如自動將審查人員新增至 CL,或找出警示系統應針對問題回報的錯誤元件

目前,中繼資料檔案的唯一用途是自動在 CL 中新增審查人員,以及在新增/提交 CL 時傳送電子郵件通知。如需相關說明,請參閱「預先提交」一節。

中繼資料檔案僅適用於第一方程式碼。

格式

中繼資料檔案如下:

中繼資料訊息類型如下:

syntax = "proto3";

// This proto is located at
// https://github.com/googleapis/googleapis/blob/master/google/type/date.proto
import "google/type/date.proto";

// IssueTracker contains the project configuration for the Google
// Issue Tracker.
message IssueTracker {
  int64 component_id = 1;
}

message Tracker {
  repeated IssueTracker issue_tracker = 2;
  // for_automation defines whether this tracker should be used by automated
  // processes (e.g. alerts).
  bool for_automation = 3;
}

message Presubmit {
  repeated string review_notify = 1;
  repeated string auto_reviewers = 2;
}

message Metadata {
  // name is the name of the API/Package/Program.
  string name = 1;
  string description = 2;
  // url points to some documentation/landing page.
  string url = 3;
  // Date this metadata was last reviewed by a human.
  google.type.Date last_reviewed_date = 4;
  repeated Tracker trackers = 5;
  // presubmits are used for defining presubmits.
  // The field is marked repeated for future expansion, but only
  // one message should be used.
  repeated Presubmit presubmits = 6;
}

以下是假的中繼資料檔案範例:

name: "Fuchsia source code automation"
description: "A binary for automating source code gardening tasks"
url: "https://fuchsia.dev"
last_reviewed_date: {
    year: 2022
    month: 1
    day: 23
}
trackers: {
  issue_tracker: {
    component_id: 1478090
  }
}

presubmits: {
  auto_reviewers: "frodo@example.com"

  review_notify: "sauron@example.com"
  review_notify: "gandalf@example.com"
}

多個中繼資料檔案

為了支援包含多個不同專案的大型存放區,檔案樹狀結構中可能會有多個 METADATA.textproto 檔案。中繼資料檔案適用於專屬的目錄和以下所有目錄。

預先提交

presubmit 欄位可讓您指定將審查者自動加入各變更清單 (auto_reviewers),以及上傳/提交變更清單時應透過電子郵件收到通知的審查者 (review_notify)。

以下是包含多個中繼資料檔案的階層範例:

├── alice
│   ├── METADATA.textproto
│   └── README.md
├── foo
│   └── bar
│       ├── baz
│       │   └── METADATA.textproto
│       │   └── server.go
│       └── METADATA.textproto
│       └── hello.rs
├── METADATA.textproto
└── README.md

每當整個存放區中的任何檔案發生變更時,系統都會新增/通知 /METADATA.textproto 中指定的審查者。/foo/bar/METADATA.textproto 中的審查人員適用於 /foo/bar 目錄和子項目錄 /foo/bar/baz 中的任何內容。/foo/bar/baz/METADATA.textproto 中的審查者只會套用至在 /foo/bar/baz/ 目錄中編輯的檔案。

與其他檔案的關係

中繼資料檔案與其他檔案沒有關聯,例如 OWNERS (用於指定目錄擁有者) 或 README.fuchsia (用於定義第三方程式碼中繼資料)。