module loghelper.repositories.pygit_helper

Inheritance diagram of pyquickhelper.loghelper.repositories.pygit_helper

Short summary

module pyquickhelper.loghelper.repositories.pygit_helper

Uses git to get version number.

source on GitHub

Classes

class

truncated documentation

GitException

Exception raised by this module.

RepoFile

Mimic a GIT file.

Functions

function

truncated documentation

__get_version_from_version_txt

Private function, tries to find a file version.txt which should contains the version number (if svn is not …

clone

Clones a git repository.

get_cmd_git

Gets the command line used to run git.

get_file_details

Returns information about a file.

get_file_details_all

Returns information about all files

get_file_last_modification

Returns the last modification of a file.

get_master_location

Gets the remote master location.

get_nb_commits

Returns the number of commit.

get_repo_log

Gets the latest changes operated on a file in a folder or a subfolder.

get_repo_version

Gets the latest check for a specific path or version number based on the date (if usedate is True). If usedate

IsRepo

Says if it a repository GIT.

my_date_conversion

Converts a date into a datetime.

rebase

Runs git pull -rebase on a repository.

repo_ls

Runs ls on a path.

Methods

method

truncated documentation

__init__

__str__

usual

Documentation

Uses git to get version number.

source on GitHub

exception pyquickhelper.loghelper.repositories.pygit_helper.GitException[source]

Bases: Exception

Exception raised by this module.

source on GitHub

pyquickhelper.loghelper.repositories.pygit_helper.IsRepo(location, commandline=True)[source]

Says if it a repository GIT.

Parameters:
  • location – (str) location

  • commandline – (bool) use commandline or not

Returns:

bool

source on GitHub

class pyquickhelper.loghelper.repositories.pygit_helper.RepoFile(**args)[source]

Bases: object

Mimic a GIT file.

source on GitHub

Parameters:

args – list of members to add

source on GitHub

__init__(**args)[source]
Parameters:

args – list of members to add

source on GitHub

__str__()[source]

usual

source on GitHub

pyquickhelper.loghelper.repositories.pygit_helper.__get_version_from_version_txt(path)[source]

Private function, tries to find a file version.txt which should contains the version number (if svn is not present).

Parameters:

path – folder to look, it will look to the the path of this file, some parents directories and finally this path

Returns:

the version number

Warning

If version.txt was not found, it throws an exception.

source on GitHub

pyquickhelper.loghelper.repositories.pygit_helper.clone(location, srv, group, project, username=None, password=None, fLOG=None)[source]

Clones a git repository.

Parameters:
  • location – location of the clone

  • srv – git server

  • group – group

  • project – project name

  • username – username

  • password – password

  • fLOG – logging function

Returns:

output, error

See How to provide username and password when run “git clone git@remote.git”?

Clone a git repository

clone("local_folder", "github.com", "sdpython", "pyquickhelper")

source on GitHub

pyquickhelper.loghelper.repositories.pygit_helper.get_cmd_git()[source]

Gets the command line used to run git.

Returns:

string

source on GitHub

pyquickhelper.loghelper.repositories.pygit_helper.get_file_details(name, path=None, commandline=True)[source]

Returns information about a file.

Parameters:
  • name – name of the file

  • path – path to repo

  • commandline – if True, use the command line to get the version number, otherwise it uses pysvn

Returns:

list of tuples

The result is a list of tuple:

  • commit

  • name

  • added

  • inserted

  • bytes

source on GitHub

pyquickhelper.loghelper.repositories.pygit_helper.get_file_details_all(path=None, commandline=True)[source]

Returns information about all files

Parameters:
  • path – path to repo

  • commandline – if True, use the command line to get the version number, otherwise it uses pysvn

Returns:

list of tuples

The result is a list of tuple:

  • commit

  • name

  • net

  • bytes

source on GitHub

pyquickhelper.loghelper.repositories.pygit_helper.get_file_last_modification(path, commandline=True)[source]

Returns the last modification of a file.

Parameters:
  • path – path to look

  • commandline – if True, use the command line to get the version number, otherwise it uses pysvn

Returns:

integer

source on GitHub

pyquickhelper.loghelper.repositories.pygit_helper.get_master_location(path=None, commandline=True)[source]

Gets the remote master location.

Parameters:
  • path – path to look

  • commandline – if True, use the command line to get the version number, otherwise it uses pysvn

Returns:

integer (check in number)

source on GitHub

pyquickhelper.loghelper.repositories.pygit_helper.get_nb_commits(path=None, commandline=True)[source]

Returns the number of commit.

Parameters:
  • path – path to look

  • commandline – if True, use the command line to get the version number, otherwise it uses pysvn

Returns:

integer

source on GitHub

pyquickhelper.loghelper.repositories.pygit_helper.get_repo_log(path=None, file_detail=False, commandline=True, subset=None)[source]

Gets the latest changes operated on a file in a folder or a subfolder.

Parameters:
  • path – path to look

  • file_detail – if True, add impacted files

  • commandline – if True, use the command line to get the version number, otherwise it uses pysvn

  • subset – only provide file details for a subset of files

Returns:

list of changes, each change is a list of tuple (see below)

The return results is a list of tuple with the following fields:

  • author

  • commit hash [:6]

  • date (datetime)

  • comment$

  • full commit hash

  • link to commit (if the repository is http://…)

The function use a command line if an error occurred. It uses the xml format:

<logentry revision="161">
    <author>xavier dupre</author>
    <date>2013-03-23T15:02:50.311828Z</date>
    <msg>pyquickhelper: first version</msg>
    <hash>full commit hash</hash>
</logentry>

Add link:

https://github.com/sdpython/pyquickhelper/commit/8d5351d1edd4a8997f358be39da80c72b06c2272

More: git pretty format See also pretty format (html). To get details about one file and all the commit.

git log  --stat -- _unittests/ut_loghelper/data/sample_zip.zip

For some reason, the call to str2datetime seemed to cause exception such as:

File "<frozen importlib._bootstrap>", line 2212, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2224, in _find_and_load_unlocked

when it was used to generate documentation for others modules than pyquickhelper. Not using this function helps. The cause still remains obscure.

source on GitHub

pyquickhelper.loghelper.repositories.pygit_helper.get_repo_version(path=None, commandline=True, usedate=False, log=False)[source]

Gets the latest check for a specific path or version number based on the date (if usedate is True). If usedate is False, it returns a mini hash (a string then).

Parameters:
  • path – path to look

  • commandline – if True, use the command line to get the version number, otherwise it uses pysvn

  • usedate – if True, it uses the date to return a minor version number (1.1.thisone)

  • log – if True, returns the output instead of a boolean

Returns:

integer)

source on GitHub

pyquickhelper.loghelper.repositories.pygit_helper.my_date_conversion(sdate)[source]

Converts a date into a datetime.

Parameters:

sdate – string

Returns:

date

source on GitHub

pyquickhelper.loghelper.repositories.pygit_helper.rebase(location, srv, group, project, username=None, password=None, fLOG=None)[source]

Runs git pull -rebase on a repository.

Parameters:
  • location – location of the clone

  • srv – git server

  • group – group

  • project – project name

  • username – username

  • password – password

  • fLOG – logging function

Returns:

output, error

source on GitHub

pyquickhelper.loghelper.repositories.pygit_helper.repo_ls(full, commandline=True)[source]

Runs ls on a path.

Parameters:
  • full – full path

  • commandline – use command line instead of pysvn

Returns:

output of client.ls

source on GitHub