mirror of
https://git.sprinternet.at/h44z/gitlab_to_gitea.git
synced 2024-11-25 16:13:06 +00:00
Action import script
This commit is contained in:
parent
7bbfb918c5
commit
2d195562ce
34
gitea_import_actions.py
Normal file
34
gitea_import_actions.py
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
# Import commits to gitea action database.
|
||||||
|
# use:
|
||||||
|
# git log --pretty=format:'%H,%at,%s' --date=default > /tmp/commit.log
|
||||||
|
# to get the commits logfile for a repository
|
||||||
|
|
||||||
|
import mysql.connector as mariadb
|
||||||
|
|
||||||
|
# set the following variables to fit your need...
|
||||||
|
USERID = 1
|
||||||
|
REPOID = 1
|
||||||
|
BRANCH = "master"
|
||||||
|
|
||||||
|
mydb = mariadb.connect(
|
||||||
|
host="localhost",
|
||||||
|
user="user",
|
||||||
|
passwd="password",
|
||||||
|
database="gitea"
|
||||||
|
)
|
||||||
|
|
||||||
|
mycursor = mydb.cursor()
|
||||||
|
|
||||||
|
sql = "INSERT INTO action (user_id, op_type, act_user_id, repo_id, comment_id, ref_name, is_private, created_unix) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)"
|
||||||
|
|
||||||
|
with open("/tmp/commit.log") as f:
|
||||||
|
for line in f:
|
||||||
|
line_clean = line.rstrip('\n')
|
||||||
|
line_split = line_clean.split(',')
|
||||||
|
val = (USERID, 5, USERID, REPOID, 0, BRANCH, 1, int(line_split[1]))
|
||||||
|
print(val)
|
||||||
|
mycursor.execute(sql, val)
|
||||||
|
|
||||||
|
mydb.commit()
|
||||||
|
|
||||||
|
print("actions inserted.")
|
Loading…
Reference in New Issue
Block a user