Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

Commit

Name work items in the search contract

The results tab is items (SearchType::Items, "items"), a work item's hit is kind item (HitKind::Item), its count is SearchCounts.items, and a hit carries its workspace. The issue names are gone.

G1T-Session:
ses_01m566c35sewwsq09vknpxzh49
syntaqxcommitted Parenteaf1ec1Browse files
2 files+37−280/2 viewed
+22−15
22 //!
33 //! It covers everything public, and private content the viewer is a member
44 //! of: repositories (name, description, topics, README), code on default
5−//! branches, issues and pull requests, people and workspaces. Who may see
5+//! branches, work items and pull requests, people and workspaces. Who may see
66 //! what is decided when the query runs, against the viewer's current
77 //! memberships and each repository's current visibility, never only when
88 //! something was indexed.
2020 pub enum SearchType {
2121 Repositories,
2222 Code,
23− Issues,
23+ Items,
2424 Pulls,
2525 People,
2626 }
2929 pub const ALL: [SearchType; 5] = [
3030 SearchType::Repositories,
3131 SearchType::Code,
32− SearchType::Issues,
32+ SearchType::Items,
3333 SearchType::Pulls,
3434 SearchType::People,
3535 ];
3838 match self {
3939 SearchType::Repositories => "repositories",
4040 SearchType::Code => "code",
41− SearchType::Issues => "issues",
41+ SearchType::Items => "items",
4242 SearchType::Pulls => "pulls",
4343 SearchType::People => "people",
4444 }
4545 }
4646
4747 /// Reads a type as people write it: `repositories`, `repos`, `code`,
48− /// `issues`, `pulls`, `prs`, `people`, `users`.
48+ /// `items`, `pulls`, `prs`, `people`, `users`.
4949 pub fn parse(text: &str) -> Option<SearchType> {
5050 match text.trim().to_lowercase().as_str() {
5151 "repositories" | "repository" | "repos" | "repo" | "projects" | "project" => Some(SearchType::Repositories),
5252 "code" => Some(SearchType::Code),
53− "issues" | "issue" => Some(SearchType::Issues),
53+ "items" | "item" => Some(SearchType::Items),
5454 "pulls" | "pull" | "prs" | "pr" | "pull_requests" | "pull-requests" => Some(SearchType::Pulls),
5555 "people" | "users" | "user" | "workspaces" | "workspace" => Some(SearchType::People),
5656 _ => None,
107107 pub enum HitKind {
108108 Repository,
109109 Code,
110− Issue,
110+ Item,
111111 Pull,
112112 User,
113113 Workspace,
123123 pub title: String,
124124 /// Where it is on g1t.sh, as a path: `/acme/web/blob/main/src/app.rs#L12`.
125125 pub url: String,
126− /// The repository, as `owner/name`, for everything but people.
126+ /// The repository, as `owner/name`, for everything but people and
127+ /// workspaces: for a work item, the one it was filed in, if any.
127128 #[serde(default)]
128129 pub repo: Option<String>,
130+ /// For a work item: its workspace's slug.
131+ #[serde(default)]
132+ pub workspace: Option<String>,
129133 /// Whether only members of its workspace can see it.
130134 #[serde(default)]
131135 pub private: bool,
148152 /// For code: the branch it was read from.
149153 #[serde(default, rename = "ref")]
150154 pub git_ref: Option<String>,
151− /// For issues and pull requests.
155+ /// For work items and pull requests.
152156 #[serde(default)]
153157 pub number: Option<u32>,
154− /// `open` or `closed` for an issue; `draft`, `open`, `merged` or
158+ /// `open` or `closed` for a work item; `draft`, `open`, `merged` or
155159 /// `closed` for a pull request.
156160 #[serde(default)]
157161 pub state: Option<String>,
158− /// Who opened the issue or pull request: `g1t` for one g1t made.
162+ /// Who opened the work item or pull request: `g1t` for one g1t made.
159163 #[serde(default)]
160164 pub author: Option<String>,
161− /// For an issue or pull request g1t opened: who asked for it.
165+ /// For a work item or pull request g1t opened: who asked for it.
162166 #[serde(default)]
163167 pub requested_by: Option<String>,
164168 #[serde(default)]
184188 title: title.into(),
185189 url: url.into(),
186190 repo: None,
191+ workspace: None,
187192 private: false,
188193 description: None,
189194 snippet: Vec::new(),
209214 pub struct SearchCounts {
210215 pub repositories: u32,
211216 pub code: u32,
212− pub issues: u32,
217+ pub items: u32,
213218 pub pulls: u32,
214219 pub people: u32,
215220 }
219224 match kind {
220225 SearchType::Repositories => self.repositories,
221226 SearchType::Code => self.code,
222− SearchType::Issues => self.issues,
227+ SearchType::Items => self.items,
223228 SearchType::Pulls => self.pulls,
224229 SearchType::People => self.people,
225230 }
229234 let slot = match kind {
230235 SearchType::Repositories => &mut self.repositories,
231236 SearchType::Code => &mut self.code,
232− SearchType::Issues => &mut self.issues,
237+ SearchType::Items => &mut self.items,
233238 SearchType::Pulls => &mut self.pulls,
234239 SearchType::People => &mut self.people,
235240 };
331336 assert_eq!(SearchType::parse("prs"), Some(SearchType::Pulls));
332337 assert_eq!(SearchType::parse("Repos"), Some(SearchType::Repositories));
333338 assert_eq!(SearchType::parse("users"), Some(SearchType::People));
339+ assert_eq!(SearchType::parse("items"), Some(SearchType::Items));
340+ assert_eq!(SearchType::parse("issues"), None);
334341 assert_eq!(SearchType::parse("wiki"), None);
335342 }
336343
+15−13
44
55 /**
66 * Search across all of g1t: repositories (name, description, topics,
7− * README), code on default branches, issues and pull requests, people and
7+ * README), code on default branches, work items and pull requests, people and
88 * workspaces. Everything public, and private content the viewer is a member
99 * of, decided when the query runs. Mirrors `crates/contracts/src/search.rs`.
1010 */
1111
1212 /** One tab of results. */
13−export type SearchType = "repositories" | "code" | "issues" | "pulls" | "people";
13+export type SearchType = "repositories" | "code" | "items" | "pulls" | "people";
1414
15−export const SEARCH_TYPES: SearchType[] = ["repositories", "code", "issues", "pulls", "people"];
15+export const SEARCH_TYPES: SearchType[] = ["repositories", "code", "items", "pulls", "people"];
1616
1717 /** The most results on one page, and how many a page has when none is asked for. */
1818 export const MAX_PER_PAGE = 50;
2626 /** A line of code in a result, numbered from 1. */
2727 export type CodeLine = { number: number; parts: Segment[] };
2828
29−export type HitKind = "repository" | "code" | "issue" | "pull" | "user" | "workspace";
29+export type HitKind = "repository" | "code" | "item" | "pull" | "user" | "workspace";
3030
3131 /** One result. Which fields are set depends on `kind`. */
3232 export type SiteHit = {
3333 kind: HitKind;
34− /** `acme/web`, a file's path, an issue's title, a person's name. */
34+ /** `acme/web`, a file's path, a work item's title, a person's name. */
3535 title: string;
3636 /** A path on g1t.sh: `/acme/web/blob/main/src/app.rs#L12`. */
3737 url: string;
38− /** `owner/name`, for everything but people. */
38+ /** `owner/name`, for everything but people: for a work item, the one it was filed in, if any. */
3939 repo: string | null;
40+ /** For a work item: its workspace's slug. */
41+ workspace?: string | null;
4042 private: boolean;
4143 description: string | null;
4244 snippet: Segment[];
4648 language: string | null;
4749 ref: string | null;
4850 number: number | null;
49− /** `open`/`closed` for an issue; `draft`/`open`/`merged`/`closed` for a pull request. */
51+ /** `open`/`closed` for a work item; `draft`/`open`/`merged`/`closed` for a pull request. */
5052 state: string | null;
51− /** Who opened the issue or pull request: `g1t` for one g1t made. */
53+ /** Who opened the work item or pull request: `g1t` for one g1t made. */
5254 author: string | null;
53− /** For an issue or pull request g1t opened: who asked for it. */
55+ /** For a work item or pull request g1t opened: who asked for it. */
5456 requestedBy?: string | null;
5557 labels: string[];
5658 topics: string[];
107109 query: string,
108110 options?: { type?: SearchType | null; page?: number; perPage?: number },
109111 ): Promise<Result<SearchResults>>;
110− /** A few repositories, issues, pull requests and people, as someone types. */
112+ /** A few repositories, work items, pull requests and people, as someone types. */
111113 suggest(viewer: Viewer, query: string): Promise<SiteHit[]>;
112114 /** Public repositories, recently active or new, by language or topic. */
113115 explore(
150152 return "repositories";
151153 case "code":
152154 return "code";
153− case "issues":
154− case "issue":
155− return "issues";
155+ case "items":
156+ case "item":
157+ return "items";
156158 case "pulls":
157159 case "prs":
158160 case "pr":

Comments

Sign in to comment.