Skip to content

Commit

Permalink
[Penify]: Documentation for commit - 4ec3dac (#29)
Browse files Browse the repository at this point in the history
* [Penify]: Documentation for commit - 4ec3dac

* [Penify]: Documentation for commit - 4ec3dac

---------

Co-authored-by: penify-dev[bot] <146478655+penify-dev[bot]@users.noreply.github.com>
  • Loading branch information
penify-dev[bot] authored Oct 21, 2024
1 parent 4ec3dac commit d0279a5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
11 changes: 11 additions & 0 deletions penify_hook/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,17 @@ def get_token(passed_token):
return None

def main():
"""Main entry point for the Penify CLI tool.
This function sets up the command-line interface (CLI) for managing Git
hooks and generating documentation. It utilizes the argparse library to
define various subcommands, including installing and uninstalling Git
hooks, generating documentation, committing changes, and logging in to
obtain an API token. The function also handles the retrieval of the API
token based on user input or environment variables and executes the
appropriate subcommand based on user selection.
"""

parser = argparse.ArgumentParser(description="Penify CLI tool for managing Git hooks and generating documentation.")

parser.add_argument("-t", "--token", help="API token for authentication. If not provided, will check PENIFY_API_TOKEN environment variable, then .penify config file.")
Expand Down
18 changes: 18 additions & 0 deletions penify_hook/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@ class GitRepoNotFoundError(Exception):
pass

def find_git_parent(path):
"""Find the parent directory of a Git repository.
This function traverses up the directory structure from the given path
to locate the nearest parent directory that contains a `.git` folder. If
such a directory is found, it returns the path to that directory. If no
Git repository is found in the specified path or any of its parent
directories, it raises a custom exception.
Args:
path (str): The path from which to start searching for the Git repository.
Returns:
str: The absolute path to the parent directory containing the `.git` folder.
Raises:
GitRepoNotFoundError: If no Git repository is found in the specified path or any
"""

current_dir = os.path.abspath(path)

while current_dir != os.path.dirname(current_dir): # Traverse up to the root directory
Expand Down

0 comments on commit d0279a5

Please sign in to comment.