Utilities

Note

The documentation in this section is aimed at people wishing to contribute to hubugs, and can be skipped if you are simply using the tool from the command line.

hubugs.utils.setup_environment(__project, __host_url)

Configure execution environment for commands dispatch.

Convenience functions

hubugs.utils.get_editor()

Choose a suitable editor.

See git-var(1) for details.

Return type

List[str]

Returns

Users chosen editor, or vi if not set

hubugs.utils.pager(__text, pager=False)

Pass output through pager.

Parameters

Git/GitHub support

hubugs.utils.get_github_api()

Create a GitHub API instance.

Returns

GitHub HTTP session

Return type

httplib2.Http

hubugs.utils.get_git_config_val(__key, default=None, local_only=False)

Fetch a git configuration value.

Parameters
  • __key (str) – Configuration value to fetch

  • default (Optional[str]) – Default value to use, if key isn’t set

  • local_only (Optional[bool]) – Fetch configuration values from repo config only

Return type

str

Returns

Git config value, if set

hubugs.utils.set_git_config_val(__key, __value, local_only=False)

Set a git configuration value.

Parameters
  • __key (str) – Configuration value to fetch

  • __value (str) – Value to set

  • local_only (Optional[bool]) – Set configuration values from repo config only

hubugs.utils.get_repo()

Extract GitHub project name from git/hg config.

We check the git config for hubugs.project, and then fall back to remote.origin.url. If both of these fail we check a mercurial root, to satisfy the hg-git users.

Return type

str

Returns

GitHub project name, including user

hubugs.utils.sync_labels(__globs, __add, __create)

Manage labels for a project.

Parameters

globs – Global argument configuration

Return type

List[str]

Returns

List of project’s label names