Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
Discussion options

I need to use GItPython API to get annotated tags. If I do next:

repo = git.Repo(repo_path) tags = repo.tags annotated_tags = [tag for tag in tags]
I get list of lightweight tags. How do I get a list of annotated tags?
I need for annotated tags info: tag, tagger, tagged_date
Thanks for any help

You must be logged in to vote

Maybe this helps: https://chatgpt.com/share/b1010a46-8079-414e-89ab-da43b2af90b9 .

Here is a copy of the code it produced:

import git
# Path to your repository
repo_path = '/path/to/your/repo'
# Initialize the Repo object
repo = git.Repo(repo_path)
# Get all tags
all_tags = repo.tags
# Filter annotated tags
annotated_tags = [tag for tag in all_tags if tag.tag is not None]
# Print the annotated tags
for tag in annotated_tags:
 print(f"Annotated Tag: {tag.name}")
 print(f"Tag Message: {tag.tag.message}")
 print(f"Tag Object: {tag.tag.object}")

Replies: 1 comment

Comment options

Maybe this helps: https://chatgpt.com/share/b1010a46-8079-414e-89ab-da43b2af90b9 .

Here is a copy of the code it produced:

import git
# Path to your repository
repo_path = '/path/to/your/repo'
# Initialize the Repo object
repo = git.Repo(repo_path)
# Get all tags
all_tags = repo.tags
# Filter annotated tags
annotated_tags = [tag for tag in all_tags if tag.tag is not None]
# Print the annotated tags
for tag in annotated_tags:
 print(f"Annotated Tag: {tag.name}")
 print(f"Tag Message: {tag.tag.message}")
 print(f"Tag Object: {tag.tag.object}")
You must be logged in to vote
0 replies
Answer selected by AlesyaSeliazniova30032012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
Converted from issue

This discussion was converted from issue #1936 on July 04, 2024 17:27.

AltStyle によって変換されたページ (->オリジナル) /