MCPcopy
hub / github.com/Shpota/github-activity-generator / main

Function main

contribute.py:11–55  ·  view source on GitHub ↗
(def_args=sys.argv[1:])

Source from the content-addressed store, hash-verified

9
10
11def main(def_args=sys.argv[1:]):
12 args = arguments(def_args)
13 curr_date = datetime.now()
14 directory = 'repository-' + curr_date.strftime('%Y-%m-%d-%H-%M-%S')
15 repository = args.repository
16 user_name = args.user_name
17 user_email = args.user_email
18 if repository is not None:
19 start = repository.rfind('/') + 1
20 end = repository.rfind('.')
21 directory = repository[start:end]
22 no_weekends = args.no_weekends
23 frequency = args.frequency
24 days_before = args.days_before
25 if days_before < 0:
26 sys.exit('days_before must not be negative')
27 days_after = args.days_after
28 if days_after < 0:
29 sys.exit('days_after must not be negative')
30 os.mkdir(directory)
31 os.chdir(directory)
32 run(['git', 'init', '-b', 'main'])
33
34 if user_name is not None:
35 run(['git', 'config', 'user.name', user_name])
36
37 if user_email is not None:
38 run(['git', 'config', 'user.email', user_email])
39
40 start_date = curr_date.replace(hour=20, minute=0) - timedelta(days_before)
41 for day in (start_date + timedelta(n) for n
42 in range(days_before + days_after)):
43 if (not no_weekends or day.weekday() < 5) \
44 and randint(0, 100) < frequency:
45 for commit_time in (day + timedelta(minutes=m)
46 for m in range(contributions_per_day(args))):
47 contribute(commit_time)
48
49 if repository is not None:
50 run(['git', 'remote', 'add', 'origin', repository])
51 run(['git', 'branch', '-M', 'main'])
52 run(['git', 'push', '-u', 'origin', 'main'])
53
54 print('\nRepository generation ' +
55 '\x1b[6;30;42mcompleted successfully\x1b[0m!')
56
57
58def contribute(date):

Callers 1

contribute.pyFile · 0.85

Calls 4

argumentsFunction · 0.85
runFunction · 0.85
contributions_per_dayFunction · 0.85
contributeFunction · 0.85

Tested by

no test coverage detected