Skip to main content

Module project_link

Module project_link 

Source
Expand description

.semora: marks a folder as a Semora project, and where a push came from.

The file is TOML meant to be committed:

server = "3f9c0e7a5b1d4e2f8a6c9b0d1e2f3a4b"
project = "semora"

server is the id the server gave itself, so the file does not say where the server is. It is only compared with the id of the configured server, never used to reach one: a cloned repository must not be able to send your API key to another host. A file from before ids holds the server’s URL; one for the configured server is moved to the id on first use.

Structs§

FileLink
A .semora as it is written, before the CLI has asked its server whether the file is for it.
Link
A .semora that is for the server this command uses.
Mapped
The record a link is used through, and the config folder that holds it.
OtherServer
A .semora names another server than the one this command uses. Commands add their own way out (push: --id or --new).

Enums§

Fit
How a .semora relates to the server this command uses.
ServerRef
What a .semora names its server by.

Constants§

FILE

Functions§

adopt
The project has the id slug on the server now. Rewrites .semora (or, for a link used through a record on this machine, the record) and the checkout record to it and says so. Any other answer leaves the link as it is.
find
Looks for .semora in the path’s folder and each parent. The nearest file wins. The current directory plays no part. Err means a file was found but is unusable.
fit
How file relates to the server client uses. An id that differs from the cached one is checked once more with the server, in case the address now leads to another server. A file for another server may still be used here through a record on this machine.
follow
The project as the server knows it now. An owner can give a project a new id; while the old one is an alias the server answers it with the new one. When the old id is gone, a document this folder pulled or pushed still says which project it is in. Errors other than a missing project are left for the command itself to report.
git_branch
The branch of the git checkout the path is in, read from HEAD (no git process). A worktree’s .git is a file that names its git folder; a relative name is relative to the folder that holds that file. The walk starts from std::path::absolute, not canonicalize: on Windows a canonical path is a \\?\ path, and those do not resolve .. or /, so the relative name is joined and cleaned up lexically instead.
origin_for
Where a push came from: machine · branch, or just the machine.
read_at
The .semora in dir itself, if there is one.
resolve
file as a link for the server client uses, or the error that says why it is not and what to do. Nothing is sent for the project before this answers.
server_value
The server value of a file as local records key it.
set_line
Sets the key line (project or server) of dir/.semora to value, keeping every other line as it is.
shown
A path for messages: without the \\?\ prefix that canonicalize adds on Windows.
slug_from
A project id from a directory name: lowercase it, turn every run of other characters into one -, trim - from both ends, cut to 40 characters, trim again.
valid_slug
[a-z0-9-], 1 to 40 characters, not starting with a dash.
write
Writes dir/.semora naming the server by its id. Returns its path.