File: git-clone-progress.rst

package info (click to toggle)
python-pygit2 1.18.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,720 kB
  • sloc: ansic: 12,584; python: 9,337; sh: 205; makefile: 26
file content (20 lines) | stat: -rw-r--r-- 668 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
**********************************************************************
git-clone with progress monitor
**********************************************************************

Example for cloning a git repository with progress monitoring:

.. code-block:: bash

   $ git clone https://github.com/libgit2/pygit2

.. code-block:: python

    class MyRemoteCallbacks(pygit2.RemoteCallbacks):

        def transfer_progress(self, stats):
            print(f'{stats.indexed_objects}/{stats.total_objects}')

    print("Cloning pygit2")
    pygit2.clone_repository("https://github.com/libgit2/pygit2", "pygit2.git",
                            callbacks=MyRemoteCallbacks())