Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add git-contributors.py to regenerate opensource contributors list #644

Merged
merged 5 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
430 changes: 171 additions & 259 deletions Descent3/credits.cpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Descent3/credits.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@
* $NoKeywords: $
*/

void Credits_Display(void);
void Credits_Display();
13 changes: 3 additions & 10 deletions Descent3/descent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,6 @@
* $NoKeywords: $
*/

#include <algorithm>
#include <cstdlib>
#include <filesystem>
#include <vector>
Expand All @@ -408,6 +407,7 @@
#include "args.h"
#include "multi_dll_mgr.h"
#include "localization.h"
#include "uisys.h"

// ---------------------------------------------------------------------------
// Variables
Expand All @@ -434,10 +434,6 @@ std::filesystem::path Descent3_temp_directory; // temp directory to put temp fil
// ---------------------------------------------------------------------------
// #define BETA

#if (defined(OEM) || defined(DEMO))
void ShowStaticScreen(char *bitmap_filename, bool timed = false, float delay_time = 0.0f);
#endif

char Proxy_server[200] = "";
int16_t Proxy_port = 80;

Expand Down Expand Up @@ -597,10 +593,8 @@ void MainLoop() {
SetScreenMode(SM_NULL);
}

#if (defined(OEM) || defined(DEMO) || defined(RELEASE))
// Shows a fullscreen static bitmap
void ShowStaticScreen(char *bitmap_filename, bool timed, float delay_time) {
extern void ui_SetScreenMode(int w, int h);
void ShowStaticScreen(const char *bitmap_filename, bool timed, float delay_time) {
chunked_bitmap splash_bm;

// do splash screen on release
Expand All @@ -615,7 +609,7 @@ void ShowStaticScreen(char *bitmap_filename, bool timed, float delay_time) {

bm_FreeBitmap(bm_handle);
float start_time = timer_GetTime();
while (1) {
while (true) {
StartFrame();

rend_DrawChunkedBitmap(&splash_bm, 0, 0, 255);
Expand Down Expand Up @@ -646,7 +640,6 @@ void ShowStaticScreen(char *bitmap_filename, bool timed, float delay_time) {

ui_SetScreenMode(Max_window_w, Max_window_h);
}
#endif

// ---------------------------------------------------------------------------
// Accessor functions
Expand Down
3 changes: 3 additions & 0 deletions Descent3/descent.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ void D3DeferHandler(bool is_active);
void SetFunctionMode(function_mode mode);
function_mode GetFunctionMode();

// Shows a fullscreen static bitmap
void ShowStaticScreen(const char *bitmap_filename, bool timed = false, float delay_time = 0.0f);

#ifndef RELEASE
// this is called when you hit a debug break!
void D3DebugStopHandler();
Expand Down
3 changes: 0 additions & 3 deletions Descent3/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1722,9 +1722,6 @@ void InitMessage(const char *c, float progress) {
}

//////////////////////////////////////////////////////////////////////////////
#if (defined(OEM) || defined(DEMO) || defined(RELEASE))
void ShowStaticScreen(char *bitmap_filename, bool timed = false, float delay_time = 0.0f);
#endif

void IntroScreen() {
// #if (defined(OEM) || defined(DEMO) )
Expand Down
1 change: 1 addition & 0 deletions scripts/data/fullhog/d3-linux-fullhog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ LEVELS2.str
pxomain.ogf
pxogame.ogf
gamecredits.txt
oscredits.txt
loki.ogf
aigame2.so
AIGame3.so
Expand Down
1 change: 1 addition & 0 deletions scripts/data/fullhog/d3-osx-fullhog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ LEVELS2.str
pxomain.ogf
pxogame.ogf
gamecredits.txt
oscredits.txt
loki.ogf
aigame2.dylib
AIGame3.dylib
Expand Down
1 change: 1 addition & 0 deletions scripts/data/fullhog/d3-win-fullhog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ LEVELS2.str
pxomain.ogf
pxogame.ogf
gamecredits.txt
oscredits.txt
loki.ogf
aigame2.dll
AIGame3.dll
Expand Down
48 changes: 48 additions & 0 deletions scripts/data/fullhog/oscredits.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
; This file was autogenerated by git-contributors.py


*320 100 320 100 8
!OPEN SOURCE CONTRIBUTORS

https://github.com/DescentDevelopers/Descent3

Andrew Grigorev
Azamat H. Hackimov
Bernhard M. Wiedemann
Bryan Perris
C.W. "Madd The Sane" Betts
Chris Sarbora
Christian Baumann
Dan Raviv
Daniel Gibson
Edu Garcia
Eric Slutz
GravisZro
InsanityBringer
Jacob Coby
Jan Engelhardt
Jason Yundt
Jeff Slutter
JeodC
Kevin Bentley
Kevin Caccamo
Kreeblah
Louis Gombert
Martin
Matt Stephenson
Oskar Strengbohm
Peter Simard
Phil Ashby
Ryan C. Gordon
Sebastian Holtermann
Taylor Richards
Thomas Otto
Thomas Ross
bperris
scivision
sirken
thfrwn
vlohacks
ziplantil

END
24 changes: 24 additions & 0 deletions tools/git-contributors/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# git-contributors.py

**git-contributors.py** - script to generate contributors list from git history.

## Requirements

* Recent python (3.12+)
* GitPython package (https://pypi.org/project/GitPython/)

## Usage

Just run `git-contributors.py`, review and commit `scripts/data/fullhog/oscredits.txt`.
You're now awesome.

**Remember regenerate file before releasing new version!**

## Customization

Tool provides two ways of customization:

* Exclude particular name from list of contributors (file `no-add.txt`,
one name per line, comments begins with `#`).
* Replace name in list of contributors with other one (file `map-names.txt`,
one entry per line in format `git_name:replace_name`, comments begins with `#`).
83 changes: 83 additions & 0 deletions tools/git-contributors/git-contributors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/usr/bin/python3

# Descent 3
# Copyright (C) 2024 Descent Developers
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from git import Repo
import argparse
import re


def strip_comments(code):
code = str(code)
return re.sub(r'(#.*)?\n?', '', code)


def main():
parser = argparse.ArgumentParser(
prog="git-contributors.py",
description="Script to generate contributors list from git history.",
)
parser.add_argument(
"--output", "-o",
required=False,
default="../../scripts/data/fullhog/oscredits.txt",
help="output file",
)
args = parser.parse_args()

noadds = list()
name_maps = dict()
with open("no-add.txt") as noadd_file:
for line in noadd_file:
name = strip_comments(line)
noadds.append(name.strip())
with open("map-names.txt") as map_file:
for line in map_file:
(git_name, replace_name) = strip_comments(line.strip()).split(":")
name_maps.update({git_name: replace_name})

repo = Repo(search_parent_directories=True)
commits = list(repo.iter_commits("main"))
authors = set()

for commit in commits:
if commit.author.name not in noadds:
if commit.author.name in name_maps.keys():
authors.add(name_maps[commit.author.name])
else:
authors.add(commit.author.name)

with open(args.output, "w") as result_file:
result_file.write("; This file was autogenerated by git-contributors.py\n")
result_file.write("\n")
result_file.write("\n")
result_file.write("*320 100 320 100 8\n")
result_file.write("!OPEN SOURCE CONTRIBUTORS\n")
result_file.write("\n")
result_file.write("https://github.com/DescentDevelopers/Descent3\n")
result_file.write("\n")

for author in sorted(authors):
result_file.write(f"{author}\n")

result_file.write("\n")
result_file.write("END\n")
print("All done!")


if __name__ == "__main__":
main()
2 changes: 2 additions & 0 deletions tools/git-contributors/map-names.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
C.W. Betts:C.W. "Madd The Sane" Betts
Thomas Roß:Thomas Ross # No ß in current font
2 changes: 2 additions & 0 deletions tools/git-contributors/no-add.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Edu García # Superseded by 'Edu Garcia'
Jeod # Superseded by 'JeodC'
Loading