greening.helpers
- greening.helpers.generate_git_section()[source]
Generate the Git configuration block for greening.yaml.
Returns a YAML-formatted string with recommended Git settings: - Suggests a git_remote URL based on the local Git username and slug - Enables or disables automatic GitHub repo creation and pushing
based on the presence of GITHUB_TOKEN
- Returns:
A YAML snippet containing Git-related configuration.
- Return type:
str
- greening.helpers.get_git_config_email()[source]
Get the Git email from global git config.
- Returns:
The Git email if found, otherwise None.
- Return type:
str or None
- greening.helpers.get_git_config_username()[source]
Get the Git username from global git config.
- Returns:
The Git username if found, otherwise None.
- Return type:
str or None
- greening.helpers.has_github_token()[source]
Check if a GitHub token is set in the environment.
- Returns:
True if GITHUB_TOKEN is present in the environment, False otherwise.
- Return type:
bool
- greening.helpers.run_git(command, cwd)[source]
Run a Git command in a subprocess.
Uses shlex.split() to safely tokenize the command string, then executes it using subprocess.run() with the specified working directory.
- Parameters:
command (str) – The full Git command as a string, e.g., ‘git commit -m “message”’.
cwd (Path) – The working directory in which to run the command.
- Raises:
subprocess.CalledProcessError – If the Git command fails.
- Return type:
None