Skip to main content

Getting git logs in a csv

Project description

Python package for reading git logs

Example usage:

import argparse
import webbrowser
from datetime import datetime

import get_git_logs as gl

# Example
# python example_gl.py --git_folder  <git_folder>  --from_date 2023-08-01 --output_csv ~/git-functions/commit_logs.csv
def main():
    parser = argparse.ArgumentParser(description='List Git commit logs for a given folder')
    parser.add_argument('--git_folder', type=str, help='Path to the Git repository folder')
    parser.add_argument('--from_date', type=str, help='Filter commits from the specified date (YYYY-MM-DD)')
    parser.add_argument('--output_csv', type=str, help='Specify the output CSV file')
    args = parser.parse_args()

    git_folder = args.git_folder
    from_date_str = args.from_date
    from_date = datetime.strptime(from_date_str, '%Y-%m-%d') if from_date_str else None
    commit_logs = gl.get_git_commit_logs(git_folder, from_date)

    if args.output_csv:
        output_csv = args.output_csv
        gl.save_to_csv(commit_logs, output_csv)
        print(f'Commit logs saved to {output_csv}')
        
        # Copy CSV content to clipboard
        with open(output_csv, 'r') as csv_file:
            csv_content = csv_file.read()
            gl.copy_to_clipboard(csv_content)
            print('CSV content copied to clipboard')

        # Open the specified URL with the CSV data
        web_url = f'https://mohan-chinnappan-n5.github.io/viz/datatable/dt.html?c=csv'
        webbrowser.open(web_url)

    else:
        print('Commit Logs:')
        for commit in commit_logs:
            print(commit)

main()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cmsgitlogs-0.0.2.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

cmsgitlogs-0.0.2-py3-none-any.whl (2.6 kB view details)

Uploaded Python 3

File details

Details for the file cmsgitlogs-0.0.2.tar.gz.

File metadata

  • Download URL: cmsgitlogs-0.0.2.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for cmsgitlogs-0.0.2.tar.gz
Algorithm Hash digest
SHA256 c091bed97473ef688711a9f1300baa2f70ef7767c2a638063c9b23d98dcedce5
MD5 601f2c76997f17250149e23c6ef15d21
BLAKE2b-256 1ce72435d4db835c3f346bc626c60cee1b2a535a4b6f3f76cdcd9d752f7ebc55

See more details on using hashes here.

File details

Details for the file cmsgitlogs-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: cmsgitlogs-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 2.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for cmsgitlogs-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d1e2ddaa2dcbe368d86841c3e5b30381e666ad567b70507d5997b62ce17dbf68
MD5 b47afcb927381a734b77c29b3cc6d7fd
BLAKE2b-256 41d10c5328cfa81d2a5d182008ba8fb4505f2336a5d7a927296153dcdeb281db

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page