mirror of
https://github.com/microsoft/WSL.git
synced 2025-12-12 07:44:25 -06:00
Many Microsoft employees have contributed to the Windows Subsystem for Linux, this commit is the result of their work since 2016. The entire history of the Windows Subsystem for Linux can't be shared here, but here's an overview of WSL's history after it moved to it own repository in 2021: Number of commits on the main branch: 2930 Number of contributors: 31 Head over https://github.com/microsoft/WSL/releases for a more detailed history of the features added to WSL since 2021.
48 lines
1.5 KiB
Python
48 lines
1.5 KiB
Python
# pip install click gitpython
|
|
|
|
# Usage:
|
|
|
|
# python tools\devops\find-release.py src/windows/wsl/main.cpp 10
|
|
# python tools\devops\find-release.py --commit 4ec2def9f3f588c06308cb31cb758e5369761aa5
|
|
|
|
import click
|
|
import re
|
|
|
|
from git import Repo, Commit, Tag
|
|
|
|
@click.command()
|
|
@click.argument('ref', required=True, type=str)
|
|
@click.argument('line', default=None, required=False, type=int)
|
|
@click.option('--commit', is_flag=True)
|
|
def main(ref: str, line: int, commit: bool):
|
|
repo = Repo('.')
|
|
|
|
repo.remote('origin').fetch('--tags')
|
|
tags = list_tags(repo)
|
|
|
|
if commit:
|
|
change = repo.commit(ref)
|
|
click.secho(f'{ref}: {find_tag_for_commit(repo, tags, change)}', fg='green', bold=True)
|
|
else:
|
|
|
|
for entry in repo.blame_incremental('HEAD', ref):
|
|
if line >= entry.linenos.start and line <= entry.linenos.stop:
|
|
click.secho(f'Changed in {find_tag_for_commit(repo, tags, entry.commit)} by {entry.commit.hexsha}', fg='green', bold=True)
|
|
|
|
print(repo.git.diff(entry.commit, entry.commit.parents[0], ref) + '\n')
|
|
|
|
|
|
def list_tags(repo: Repo) -> list:
|
|
return [e for e in sorted(repo.tags, key=lambda e: e.path) if re.match('refs/tags/[0-9]+\\.[0-9]+\\.[0-9]+', e.path)]
|
|
|
|
def find_tag_for_commit(repo: Repo, tags: list, commit: Commit) -> str:
|
|
for e in tags:
|
|
merge_bases = repo.merge_base(e, commit)
|
|
|
|
if any(e == commit for e in merge_bases):
|
|
return e.path.replace('refs/tags/', '')
|
|
|
|
return "[No tag found]"
|
|
|
|
if __name__ == '__main__':
|
|
main() |