(values: Dict[str, Any])
| 924 | return f'"{escaped}"' |
| 925 | return text |
| 926 | |
| 927 | |
| 928 | def _env_text(name: str, default: str = "") -> str: |
| 929 | file_values = _read_env_file() |
| 930 | return str(file_values.get(name, os.environ.get(name, default)) or default).strip() |
| 931 | |
| 932 | |
| 933 | def _configured_reading_notes_git_branch() -> str: |
| 934 | return _env_text("PAPERFLOW_READING_NOTES_GIT_BRANCH", "main") or "main" |
| 935 | |
| 936 | |
| 937 | def _normalize_reading_notes_git_remote(remote_url: str) -> str: |
| 938 | """Prefer SSH for plain GitHub remotes so GUI sync can use the user's SSH key.""" |
| 939 | remote = str(remote_url or "").strip() |
| 940 | match = re.fullmatch(r"https://github\.com/([^/\s]+)/([^/\s]+?)(?:\.git)?/?", remote) |
| 941 | if not match: |
| 942 | return remote |
| 943 | owner, repo = match.groups() |
| 944 | return f"git@github.com:{owner}/{repo}.git" |
| 945 | |
| 946 | |
| 947 | def _configured_reading_notes_git_remote() -> str: |
| 948 | return _normalize_reading_notes_git_remote(_env_text("PAPERFLOW_READING_NOTES_GIT_REMOTE", "")) |
| 949 | |
| 950 | |
| 951 | def _default_reading_notes_git_dir() -> Optional[Path]: |
| 952 | current_year = datetime.now().year |
| 953 | notes_root = _configured_notes_root_dir() |
| 954 | if notes_root is not None: |
nothing calls this directly
no test coverage detected