gitea.cli.watch.advance
advance
Record the current state of what is watched as the baseline, on demand.
watch list detects a change and consumes it in the same breath: it reports the
difference against the cache and advances the cache past it, so the change is
announced exactly once whether or not anyone was in a position to act on it. A
consumer that was busy - its previous run still in flight, its queue full, the
thing it would have done already being done - drops the change on the floor, and
the next run has nothing to say about it.
watch list --no-advance and this command are the two halves that pull those
apart. The dry run reports without consuming, and this commits the cache once
the change has actually been handled, so a change survives until someone acts on
it rather than until someone is told about it.
What it commits is the state of the instance now, not the state the dry run
saw. It has to be: the dry run deliberately wrote nothing down, so there is no
"then" left to commit, and re-fetching is the only thing there is. The
consequence is worth stating plainly, because it is the window this pair does
not close: a change that lands between the dry run and the advance is recorded
without ever having been reported. The change_count this reports is what the
advance moved the baseline past, so a caller that compares it against the count
its dry run reported can see that window when it opens; keeping the two calls
close together is what keeps it small.
Advancing a scope the cache has never held records it and reports it as
baselined, exactly as a first watch list would - there is nothing before it to
have moved past.
Functions:
gitea.cli.watch.advance.format_record
Render what the advance did to one scope as the line it prints for it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
record
|
dict[str, Any]
|
What was recorded for the scope. |
required |
Returns:
| Type | Description |
|---|---|
str
|
One line naming the scope, how much of it was recorded, and how far the |
str
|
baseline moved - which is the part a caller checks against what its dry |
str
|
run reported. |
Source code in src/gitea/cli/watch/advance.py
gitea.cli.watch.advance.advance_command
advance_command(
ctx: Context,
owner: Annotated[
str,
Option(
"--owner",
help="Owner of the repositories and projects to watch.",
),
],
repository: Annotated[
list[str] | None,
Option(
"--repository",
help="Name of a repository to watch the open issues of. Repeat to watch several.",
),
] = None,
project_id: Annotated[
list[int] | None,
Option(
"--project-id",
help="ID of a project to watch the board of. Repeat to watch several.",
),
] = None,
state_file: Annotated[
str | None,
Option(
"--state-file",
envvar=STATE_FILE_ENV,
help="Path of the cache of issue snapshots. Defaults to the user cache directory.",
),
] = None,
account_name: Annotated[
str | None,
Option(
"--account-name",
help="Name of the account to use for authentication.",
),
] = None,
token: Annotated[
str | None,
Option(
"--token",
help="Token for authentication. If not provided, the token from the specified account will be used.",
),
] = None,
base_url: Annotated[
str | None,
Option(
"--base-url",
help="Base URL of the Gitea platform. If not provided, the base URL from the specified account will be used.",
),
] = None,
) -> None
Record the current state of what is watched as the baseline to compare against.
The counterpart of 'watch list --no-advance': the dry run reports the changes without consuming them, and this commits the cache once they have been acted on. What is committed is the state of the instance now, so a change that lands between the two is baselined without being reported; 'change_count' says how far the baseline moved, so it can be compared against what the dry run reported.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
Context
|
The Typer context. |
required |
owner
|
Annotated[str, Option('--owner', help='Owner of the repositories and projects to watch.')]
|
The owner of the repositories and projects to watch. |
required |
repository
|
Annotated[list[str] | None, Option('--repository', help='Name of a repository to watch the open issues of. Repeat to watch several.')]
|
The repositories to watch the open issues of. |
None
|
project_id
|
Annotated[list[int] | None, Option('--project-id', help='ID of a project to watch the board of. Repeat to watch several.')]
|
The projects to watch the board of. |
None
|
state_file
|
Annotated[str | None, Option('--state-file', envvar=STATE_FILE_ENV, help='Path of the cache of issue snapshots. Defaults to the user cache directory.')]
|
Path of the cache of issue snapshots. |
None
|
account_name
|
Annotated[str | None, Option('--account-name', help='Name of the account to use for authentication.')]
|
Name of the account to use for authentication. |
None
|
token
|
Annotated[str | None, Option('--token', help='Token for authentication. If not provided, the token from the specified account will be used.')]
|
Token for authentication. |
None
|
base_url
|
Annotated[str | None, Option('--base-url', help='Base URL of the Gitea platform. If not provided, the base URL from the specified account will be used.')]
|
Base URL of the Gitea platform. |
None
|
Source code in src/gitea/cli/watch/advance.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | |