Как я могу отобразить историю строк кода для репозитория git?
Вы можете получить как добавленные, так py и удаленные строки с git python log, например:
git log --shortstat --reverse --pretty=oneline
Из этого вы loc можете написать скрипт, аналогичный python тому, который вы сделали, используя python-shell эту информацию. В питоне:
#!/usr/bin/python
"""
Display the per-commit size of the current git branch.
"""
import subprocess
import re
import sys
def main(argv):
git = subprocess.Popen(["git", "log", "--shortstat", "--reverse",
"--pretty=oneline"], stdout=subprocess.PIPE)
out, err = git.communicate()
total_files, total_insertions, total_deletions = 0, 0, 0
for line in out.split('\n'):
if not line: continue
if line[0] != ' ':
# This is a description line
hash, desc = line.split(" ", 1)
else:
# This is a stat line
data = re.findall(
' (\d+) files changed, (\d+) insertions\(\+\), (\d+) deletions\(-\)',
line)
files, insertions, deletions = ( int(x) for x in data[0] )
total_files += files
total_insertions += insertions
total_deletions += deletions
print "%s: %d files, %d lines" % (hash, total_files,
total_insertions - total_deletions)
if __name__ == '__main__':
sys.exit(main(sys.argv))
python
ruby
git
lines-of-code
2021-12-03T02:53:02+00:00
2022-10-22T23:47:34+00:00
RaziHell
Вопросы с похожей тематикой, как у вопроса:
Как я могу отобразить историю строк кода для репозитория git?
Предупреждение о файлах Cookies
Мы используем файлы cookies для улучшения работы сайта. Оставаясь на нашем сайте, вы соглашаетесь с условиями использования файлов cookies. Чтобы ознакомиться с нашими Положениями о конфиденциальности и об использовании файлов cookie, нажмите здесь.