history
Functionality for tracking and managing revision history
Revision
Bases: TypedDict
Metadata on a GSB-managed version
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier |
str
|
A short, unique identifier for the revision |
required |
commit_hash |
str
|
The full hexadecimal hash associated with the revision |
required |
description |
str
|
A description of the version |
required |
timestamp |
datetime
|
The time at which the version was created |
required |
tagged |
bool
|
Whether or not this is a tagged revision |
required |
gsb |
bool
|
Whether or not this is a GSB-created revision |
required |
Source code in gsb/history.py
get_history(repo_root, tagged_only=True, include_non_gsb=False, limit=-1, since=dt.datetime(1970, 1, 1), since_last_tagged_backup=False, always_include_latest=False)
Retrieve a list of GSB-managed versions
Parameters:
Name | Type | Description | Default |
---|---|---|---|
repo_root |
Path
|
The directory containing the GSB-managed repo |
required |
tagged_only |
bool
|
By default, this method only returns tagged backups. To include
all available revisions, pass in |
True
|
include_non_gsb |
bool
|
By default, this method excludes any revisions created outside of |
False
|
limit |
int
|
By default, this method returns the entire history. To return only the
last n revisions, pass in |
-1
|
since |
date or timestamp
|
By default, this method returns the entire history. To return only
revisions made on or after a certain date, pass in |
datetime(1970, 1, 1)
|
since_last_tagged_backup |
bool
|
False by default. To return only revisions made since the last tagged
backup, pass in |
False
|
always_include_latest |
bool
|
Whether to always include the latest backup, whether or not it's tagged or GSB-managed, and ignoring any other options. Default is False. |
False
|
Returns:
Type | Description |
---|---|
list of dict
|
metadata on the requested revisions, sorted in reverse-chronological order |
Raises:
Type | Description |
---|---|
OSError
|
If the specified repo does not exist or is not a git repo |
ValueError
|
If called with |
Source code in gsb/history.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
|
log_revision(revision, idx)
Print (log) a revision
Parameters:
Name | Type | Description | Default |
---|---|---|---|
revision |
dict
|
Metadata for the revision |
required |
idx |
int | None
|
The index to give to the revision. If None is specified, the revision will be displayed with a "-" instead of a numbering. |
required |
Notes
- The version identifiers and dates are logged at the IMPORTANT (verbose=0) level
- The version descriptions are logged at the INFO (verbose=1) level
- The full version hashes are logged at the DEBUG (verbose=2) level
Source code in gsb/history.py
show_history(repo_root, numbering=1, **kwargs)
Fetch and print (log) the list of versions for the specified repo matching the given specs
Parameters:
Name | Type | Description | Default |
---|---|---|---|
repo_root |
Path
|
The directory containing the GSB-managed repo |
required |
numbering |
int | None
|
When displaying the versions, the default behavior is to number the
results, starting at 1. To set a different starting number, provide that.
To use "-" instead of numbers, pass in |
1
|
**kwargs |
Any other options will be passed directly to |
{}
|
Notes
See log_revision()
for details about what information is logged to each
log level
Returns:
Type | Description |
---|---|
list of dict
|
metadata on the requested revisions, sorted in reverse-chronological order |
Raises:
Type | Description |
---|---|
OSError
|
If the specified repo does not exist or is not a git repo |