Gitlab to Gitea migration script.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

gitea_import_actions.py 905B

12345678910111213141516171819202122232425262728293031323334
  1. # Import commits to gitea action database.
  2. # use:
  3. # git log --pretty=format:'%H,%at,%s' --date=default > /tmp/commit.log
  4. # to get the commits logfile for a repository
  5. import mysql.connector as mariadb
  6. # set the following variables to fit your need...
  7. USERID = 1
  8. REPOID = 1
  9. BRANCH = "master"
  10. mydb = mariadb.connect(
  11. host="localhost",
  12. user="user",
  13. passwd="password",
  14. database="gitea"
  15. )
  16. mycursor = mydb.cursor()
  17. 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)"
  18. with open("/tmp/commit.log") as f:
  19. for line in f:
  20. line_clean = line.rstrip('\n')
  21. line_split = line_clean.split(',')
  22. val = (USERID, 5, USERID, REPOID, 0, BRANCH, 1, int(line_split[1])) # 5 means commit
  23. print(val)
  24. mycursor.execute(sql, val)
  25. mydb.commit()
  26. print("actions inserted.")