Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
blender-dev-tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
blender
blender-dev-tools
Commits
01cc797d
Commit
01cc797d
authored
11 years ago
by
Campbell Barton
Browse files
Options
Downloads
Patches
Plain Diff
Add initial credits generator initial script (initial commit iterator)
parent
135f5550
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
utils/credits_git_gen.py
+92
-0
92 additions, 0 deletions
utils/credits_git_gen.py
with
92 additions
and
0 deletions
utils/credits_git_gen.py
0 → 100644
+
92
−
0
View file @
01cc797d
import
os
import
subprocess
class
GitCommit
:
__slots__
=
(
"
sha1
"
,
# to extract more info
"
_git_dir
"
,
)
def
__init__
(
self
,
sha1
,
git_dir
):
self
.
sha1
=
sha1
self
.
_git_dir
=
git_dir
def
_log_format
(
self
,
format
,
args
=
()):
sha1
=
self
.
sha1
.
decode
(
'
ascii
'
)
cmd
=
(
"
git
"
,
"
--git-dir
"
,
self
.
_git_dir
,
"
log
"
,
"
-1
"
,
# only this rev
sha1
,
"
--format=
"
+
format
,
)
+
args
# print(" ".join(cmd))
p
=
subprocess
.
Popen
(
cmd
,
stdout
=
subprocess
.
PIPE
,
)
return
p
.
stdout
.
read
()
@property
def
author
(
self
):
return
self
.
_log_format
(
"
%an
"
)
@property
def
body
(
self
):
return
self
.
_log_format
(
"
%B
"
)
@property
def
files
(
self
):
return
[
f
for
f
in
self
.
_log_format
(
"
format:
"
,
args
=
(
"
--name-only
"
,)).
split
(
b
"
\n
"
)
if
f
]
@property
def
files_status
(
self
):
return
[
f
.
split
(
None
,
1
)
for
f
in
self
.
_log_format
(
"
format:
"
,
args
=
(
"
--name-status
"
,)).
split
(
b
"
\n
"
)
if
f
]
class
GitCommitIter
:
__slots__
=
(
"
_path
"
,
"
_git_dir
"
,
"
_process
"
,
)
def
__init__
(
self
,
path
):
self
.
_path
=
path
self
.
_git_dir
=
os
.
path
.
join
(
path
,
"
.git
"
)
self
.
_process
=
None
def
__iter__
(
self
):
cmd
=
(
"
git
"
,
"
--git-dir
"
,
self
.
_git_dir
,
"
log
"
,
"
--format=%H
"
,
),
# print(" ".join(cmd))
self
.
_process
=
subprocess
.
Popen
(
cmd
,
stdout
=
subprocess
.
PIPE
,
)
return
self
def
__next__
(
self
):
sha1
=
self
.
_process
.
stdout
.
readline
()[:
-
1
]
if
sha1
:
return
GitCommit
(
sha1
,
self
.
_git_dir
)
else
:
raise
StopIteration
if
__name__
==
__main__
:
for
c
in
GitCommitIter
(
"
.
"
):
print
(
c
.
sha1
,
c
.
author
)
print
(
c
.
body
)
for
f
in
c
.
files_status
:
print
(
'
'
,
f
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment