1#![allow(dead_code)]
2
3pub const GITMODULES_FILE: &str = ".gitmodules";
5
6pub const SUBMODULE_SECTION_CHECK: &str = "[submodule ";
8pub const SUBMODULE_SECTION_PREFIX: &str = "[submodule \"";
9pub const SUBMODULE_SECTION_SUFFIX: &str = "\"]";
10pub const KEY_PATH: &str = "path = ";
11pub const KEY_URL: &str = "url = ";
12pub const KEY_BRANCH: &str = "branch = ";
13
14pub const REFS_HEADS_PREFIX: &str = "refs/heads/";
16
17pub const STATUS_UP_TO_DATE: &str = "up-to-date";
19pub const STATUS_BEHIND: &str = "behind";
20pub const STATUS_POPULATED: &str = "populated";
21pub const STATUS_MISSING: &str = "missing";
22pub const STATUS_CLEAN: &str = "clean";
23pub const STATUS_DIRTY: &str = "dirty";
24pub const STATUS_SYNCED: &str = "synced";
25pub const STATUS_OUT_OF_SYNC: &str = "out-of-sync";
26pub const STATUS_ON_BRANCH: &str = "on-branch";
27pub const STATUS_DETACHED_HEAD: &str = "detached-HEAD";
28pub const STATUS_WRONG_BRANCH: &str = "wrong-branch";
29pub const STATUS_NOT_POPULATED_SKIPPED: &str = "not-populated (skipped)";
30
31pub const LABEL_PARENT: &str = "parent";
33pub const LABEL_REMOTE: &str = "remote";
34pub const LABEL_RECORDED: &str = "recorded";
35pub const LABEL_LOCAL: &str = "local";
36pub const LABEL_CURRENT: &str = "current";
37pub const LABEL_EXPECTED: &str = "expected";
38pub const LABEL_UNKNOWN: &str = "(unknown)";
39
40pub fn err_read_gitmodules(e: &impl std::fmt::Display) -> String {
42 format!("Failed to read .gitmodules: {e}")
43}
44
45pub fn err_missing_path(name: &str) -> String {
46 format!("submodule '{name}' is missing 'path =' in .gitmodules")
47}
48
49pub fn err_missing_url(name: &str) -> String {
50 format!("submodule '{name}' is missing 'url =' in .gitmodules")
51}
52
53pub fn err_missing_branch(path: &str) -> String {
54 format!("submodule '{path}' is missing 'branch =' in .gitmodules")
55}
56
57pub fn err_open_index(e: &impl std::fmt::Display) -> String {
58 format!("failed to open index: {e}")
59}
60
61pub fn err_not_in_index(path: &str) -> String {
62 format!("submodule '{path}' not found in index")
63}
64
65pub fn err_create_remote(url: &str, e: &impl std::fmt::Display) -> String {
66 format!("failed to create remote for {url}: {e}")
67}
68
69pub fn err_connect_remote(url: &str, e: &impl std::fmt::Display) -> String {
70 format!("failed to connect to {url}: {e}")
71}
72
73pub fn err_list_refs(url: &str, e: &impl std::fmt::Display) -> String {
74 format!("failed to list refs at {url}: {e}")
75}
76
77pub fn err_ref_not_found(refspec: &str, url: &str) -> String {
78 format!("ref {refspec} not found at {url}")
79}
80
81pub fn err_open_repo(e: &impl std::fmt::Display) -> String {
82 format!("failed to open git repository: {e}")
83}
84
85pub fn err_open_submodule(path: &str, e: &impl std::fmt::Display) -> String {
86 format!("failed to open submodule '{path}': {e}")
87}
88
89pub fn err_get_status(path: &str, e: &impl std::fmt::Display) -> String {
90 format!("failed to get status for '{path}': {e}")
91}
92
93pub fn err_read_head(path: &str, e: &impl std::fmt::Display) -> String {
94 format!("failed to read HEAD of '{path}': {e}")
95}
96
97#[cfg(test)]
98#[path = "strings_tests.rs"]
99mod tests;