File: commit_info.py

package info (click to toggle)
git-filter-repo 2.47.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,280 kB
  • sloc: sh: 4,887; python: 4,856; makefile: 114
file content (34 lines) | stat: -rwxr-xr-x 996 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python3

"""
Please see the
  ***** API BACKWARD COMPATIBILITY CAVEAT *****
near the top of git-filter-repo
"""

import re
import datetime

import git_filter_repo as fr

def change_up_them_commits(commit, metadata):
  # Change the commit author
  if commit.author_name == b"Copy N. Paste":
    commit.author_name = b"Ima L. Oser"
    commit.author_email = b"aloser@my.corp"

  # Fix the author email
  commit.author_email = re.sub(b"@my.crp", b"@my.corp", commit.author_email)

  # Fix the committer date (bad timezone conversion in initial import)
  oldtime = fr.string_to_date(commit.committer_date)
  newtime = oldtime + datetime.timedelta(hours=-5)
  commit.committer_date = fr.date_to_string(newtime)

  # Fix the commit message
  commit.message = re.sub(b"Marketing is staffed with pansies", b"",
                          commit.message)

args = fr.FilteringOptions.parse_args(['--force'])
filter = fr.RepoFilter(args, commit_callback = change_up_them_commits)
filter.run()