skilleter-thingy 0.3.14__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- skilleter_thingy/__init__.py +0 -0
- skilleter_thingy/addpath.py +107 -0
- skilleter_thingy/console_colours.py +63 -0
- skilleter_thingy/ffind.py +535 -0
- skilleter_thingy/ggit.py +88 -0
- skilleter_thingy/ggrep.py +155 -0
- skilleter_thingy/git_br.py +186 -0
- skilleter_thingy/git_ca.py +147 -0
- skilleter_thingy/git_cleanup.py +297 -0
- skilleter_thingy/git_co.py +227 -0
- skilleter_thingy/git_common.py +68 -0
- skilleter_thingy/git_hold.py +162 -0
- skilleter_thingy/git_parent.py +84 -0
- skilleter_thingy/git_retag.py +67 -0
- skilleter_thingy/git_review.py +1450 -0
- skilleter_thingy/git_update.py +398 -0
- skilleter_thingy/git_wt.py +72 -0
- skilleter_thingy/gitcmp_helper.py +328 -0
- skilleter_thingy/gitprompt.py +293 -0
- skilleter_thingy/linecount.py +154 -0
- skilleter_thingy/multigit.py +915 -0
- skilleter_thingy/py_audit.py +133 -0
- skilleter_thingy/remdir.py +127 -0
- skilleter_thingy/rpylint.py +98 -0
- skilleter_thingy/strreplace.py +82 -0
- skilleter_thingy/test.py +34 -0
- skilleter_thingy/tfm.py +948 -0
- skilleter_thingy/tfparse.py +101 -0
- skilleter_thingy/trimpath.py +82 -0
- skilleter_thingy/venv_create.py +47 -0
- skilleter_thingy/venv_template.py +47 -0
- skilleter_thingy/xchmod.py +124 -0
- skilleter_thingy/yamlcheck.py +89 -0
- skilleter_thingy-0.3.14.dist-info/METADATA +606 -0
- skilleter_thingy-0.3.14.dist-info/RECORD +39 -0
- skilleter_thingy-0.3.14.dist-info/WHEEL +5 -0
- skilleter_thingy-0.3.14.dist-info/entry_points.txt +31 -0
- skilleter_thingy-0.3.14.dist-info/licenses/LICENSE +619 -0
- skilleter_thingy-0.3.14.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
#! /usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
""" Run 'git grep' in all Git working trees under the current directory or just
|
|
4
|
+
in the current directory if the current director is in a working tree.
|
|
5
|
+
|
|
6
|
+
Copyright (C) 2019-21 John Skilleter
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
################################################################################
|
|
10
|
+
|
|
11
|
+
import os
|
|
12
|
+
import re
|
|
13
|
+
import sys
|
|
14
|
+
import argparse
|
|
15
|
+
|
|
16
|
+
from skilleter_modules import colour
|
|
17
|
+
from skilleter_modules import git
|
|
18
|
+
|
|
19
|
+
################################################################################
|
|
20
|
+
|
|
21
|
+
BINARY_RE = re.compile(r'(Binary file )(.*)( matches)')
|
|
22
|
+
|
|
23
|
+
################################################################################
|
|
24
|
+
|
|
25
|
+
def parse_command_line():
|
|
26
|
+
""" Validate the command line, return the arguments """
|
|
27
|
+
|
|
28
|
+
parser = argparse.ArgumentParser(
|
|
29
|
+
description='Run a git grep in either the current working tree or all working git working trees under the current directory')
|
|
30
|
+
|
|
31
|
+
parser.add_argument('--follow', '-f', action='store_true', help='Follow symlinks')
|
|
32
|
+
parser.add_argument('--text', '-a', action='store_true', help='Process binary files as if they were text.')
|
|
33
|
+
parser.add_argument('--ignore-case', '-i', action='store_true', help='Ignore case differences between the patterns and the files.')
|
|
34
|
+
parser.add_argument('--word-regexp', '-w', action='store_true',
|
|
35
|
+
help='Match the pattern only at word boundary (either begin at the beginning of a line, or preceded by a non-word character; end at the end of a line or followed by a non-word character).')
|
|
36
|
+
parser.add_argument('--invert-match', '-v', action='store_true', help='Select non-matching lines.')
|
|
37
|
+
parser.add_argument('--fixed-strings', '-F', action='store_true', help='Use fixed strings for patterns (don’t interpret pattern as a regex).')
|
|
38
|
+
parser.add_argument('--line-number', '-n', action='store_true', help='Prefix the line number to matching lines.')
|
|
39
|
+
parser.add_argument('--files-with-matches', '-l', action='store_true', help='Show only the names of files that contain matches')
|
|
40
|
+
parser.add_argument('--files-without-matches', '-L', action='store_true', help='Show only the names of files that do NOT contain matches')
|
|
41
|
+
parser.add_argument('--wildcard', '-W', action='append', help='Only search files matching the wildcard(s)')
|
|
42
|
+
parser.add_argument('--only-matching', '-o', action='store_true',
|
|
43
|
+
help='Print only the matched (non-empty) parts of a matching line, with each such part on a separate output line.')
|
|
44
|
+
parser.add_argument('--no-color', action='store_true', help='Turn off match highlighting')
|
|
45
|
+
parser.add_argument('pattern', action='store', help='Regular expression to search for')
|
|
46
|
+
parser.add_argument('paths', nargs='*', help='Optional list of one or more paths to search')
|
|
47
|
+
|
|
48
|
+
return parser.parse_args()
|
|
49
|
+
|
|
50
|
+
################################################################################
|
|
51
|
+
|
|
52
|
+
def git_grep(args, path, pattern):
|
|
53
|
+
""" Grep a git """
|
|
54
|
+
|
|
55
|
+
if path == '.':
|
|
56
|
+
path = ''
|
|
57
|
+
elif path[0:2] == './':
|
|
58
|
+
path = path[2:]
|
|
59
|
+
|
|
60
|
+
grep_options = {'color': True, 'extended_regexp': True}
|
|
61
|
+
|
|
62
|
+
if args.text:
|
|
63
|
+
grep_options['text'] = True
|
|
64
|
+
|
|
65
|
+
if args.ignore_case:
|
|
66
|
+
grep_options['ignore_case'] = True
|
|
67
|
+
|
|
68
|
+
if args.word_regexp:
|
|
69
|
+
grep_options['word_regexp'] = True
|
|
70
|
+
|
|
71
|
+
if args.invert_match:
|
|
72
|
+
grep_options['invert_match'] = True
|
|
73
|
+
|
|
74
|
+
if args.fixed_strings:
|
|
75
|
+
grep_options['fixed_strings'] = True
|
|
76
|
+
|
|
77
|
+
if args.line_number:
|
|
78
|
+
grep_options['line_number'] = True
|
|
79
|
+
|
|
80
|
+
if args.files_without_matches:
|
|
81
|
+
grep_options['files_without_matches'] = True
|
|
82
|
+
|
|
83
|
+
if args.files_with_matches:
|
|
84
|
+
grep_options['files_with_matches'] = True
|
|
85
|
+
|
|
86
|
+
if args.only_matching:
|
|
87
|
+
grep_options['only_matching'] = True
|
|
88
|
+
|
|
89
|
+
if path:
|
|
90
|
+
output, status = git.grep(pattern, git_dir=os.path.join(path, '.git'), work_tree=path, options=grep_options, wildcards=args.wildcard)
|
|
91
|
+
else:
|
|
92
|
+
output, status = git.grep(pattern, options=grep_options, wildcards=args.wildcard)
|
|
93
|
+
|
|
94
|
+
if status > 1:
|
|
95
|
+
colour.error(output)
|
|
96
|
+
elif status == 0:
|
|
97
|
+
for out in output.split('\n'):
|
|
98
|
+
if out:
|
|
99
|
+
bin_match = BINARY_RE.match(out)
|
|
100
|
+
if bin_match:
|
|
101
|
+
match_path = os.path.join(path, bin_match.group(2))
|
|
102
|
+
colour.write(f'[BOLD:{match_path}]: Binary file match')
|
|
103
|
+
else:
|
|
104
|
+
subdir = os.path.join(path, out.split(':', 1)[0])
|
|
105
|
+
data = out.split(':', 1)[1]
|
|
106
|
+
|
|
107
|
+
colour.write(f'[BLUE:{subdir}]: {data.strip()}')
|
|
108
|
+
|
|
109
|
+
################################################################################
|
|
110
|
+
|
|
111
|
+
def git_grep_path(args, path):
|
|
112
|
+
""" Look for git working trees under the specified path and grep them """
|
|
113
|
+
|
|
114
|
+
for root, dirs, _ in os.walk(path, followlinks=args.follow):
|
|
115
|
+
if '.git' in dirs:
|
|
116
|
+
git_grep(args, root, args.pattern)
|
|
117
|
+
|
|
118
|
+
################################################################################
|
|
119
|
+
|
|
120
|
+
def main():
|
|
121
|
+
""" If we are in a repo, just run git grep, otherwise, hunt for
|
|
122
|
+
repos and git grep them. """
|
|
123
|
+
|
|
124
|
+
args = parse_command_line()
|
|
125
|
+
|
|
126
|
+
if not args.paths:
|
|
127
|
+
# No paths specified so if the current directory is in a working tree
|
|
128
|
+
# just run git grep, otherwise, look for working trees in subdirectories
|
|
129
|
+
|
|
130
|
+
if git.working_tree():
|
|
131
|
+
git_grep(args, '.', args.pattern)
|
|
132
|
+
else:
|
|
133
|
+
args.paths = ['.']
|
|
134
|
+
|
|
135
|
+
if args.paths:
|
|
136
|
+
for path in args.paths:
|
|
137
|
+
git_grep_path(args, path)
|
|
138
|
+
|
|
139
|
+
################################################################################
|
|
140
|
+
|
|
141
|
+
def ggrep():
|
|
142
|
+
"""Entry point"""
|
|
143
|
+
|
|
144
|
+
try:
|
|
145
|
+
main()
|
|
146
|
+
|
|
147
|
+
except KeyboardInterrupt:
|
|
148
|
+
sys.exit(1)
|
|
149
|
+
except BrokenPipeError:
|
|
150
|
+
sys.exit(2)
|
|
151
|
+
|
|
152
|
+
################################################################################
|
|
153
|
+
|
|
154
|
+
if __name__ == '__main__':
|
|
155
|
+
ggrep()
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
#! /usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
################################################################################
|
|
4
|
+
""" Thingy 'git-br' command - output branch information
|
|
5
|
+
|
|
6
|
+
Author: John Skilleter
|
|
7
|
+
|
|
8
|
+
Licence: GPL v3 or later
|
|
9
|
+
|
|
10
|
+
TODO: Command line options for list of fields to output
|
|
11
|
+
TODO: Command line options for sort order
|
|
12
|
+
TODO: Debate the delete option, which currently isn't implemented
|
|
13
|
+
"""
|
|
14
|
+
################################################################################
|
|
15
|
+
|
|
16
|
+
import os
|
|
17
|
+
import sys
|
|
18
|
+
import argparse
|
|
19
|
+
import fnmatch
|
|
20
|
+
import datetime
|
|
21
|
+
|
|
22
|
+
from dateutil.parser import parse
|
|
23
|
+
from dateutil.relativedelta import relativedelta
|
|
24
|
+
|
|
25
|
+
from skilleter_modules import git
|
|
26
|
+
from skilleter_modules import colour
|
|
27
|
+
|
|
28
|
+
################################################################################
|
|
29
|
+
|
|
30
|
+
def parse_command_line():
|
|
31
|
+
""" Parse the command line """
|
|
32
|
+
|
|
33
|
+
parser = argparse.ArgumentParser(description='List or delete branches that have been merged')
|
|
34
|
+
|
|
35
|
+
parser.add_argument('--all', '-a', action='store_true', help='List all branches, including remotes')
|
|
36
|
+
parser.add_argument('--delete', '-d', action='store_true',
|
|
37
|
+
help='Delete the specified branch(es), even if it is the current one (list of branches to delete must be supplied as parameters)')
|
|
38
|
+
parser.add_argument('--path', '-C', nargs=1, type=str, default=None,
|
|
39
|
+
help='Run the command in the specified directory')
|
|
40
|
+
parser.add_argument('branches', nargs='*', help='Filter the list of branches according to one or more patterns')
|
|
41
|
+
|
|
42
|
+
args = parser.parse_args()
|
|
43
|
+
|
|
44
|
+
if args.path:
|
|
45
|
+
os.chdir(args.path[0])
|
|
46
|
+
|
|
47
|
+
if args.delete and not args.branches:
|
|
48
|
+
colour.error('You must specify the branches to delete', prefix=True)
|
|
49
|
+
|
|
50
|
+
return args
|
|
51
|
+
|
|
52
|
+
################################################################################
|
|
53
|
+
|
|
54
|
+
def branch_match(ref, matching_branches):
|
|
55
|
+
""" Return True if ref matches an entry in matching_branches """
|
|
56
|
+
|
|
57
|
+
if matching_branches:
|
|
58
|
+
for branch in matching_branches:
|
|
59
|
+
if '?' in branch or '*' in branch:
|
|
60
|
+
if branch[0] not in ['?', '*']:
|
|
61
|
+
branch = f'*{branch}'
|
|
62
|
+
if branch[-1] not in ['?', '*']:
|
|
63
|
+
branch = f'{branch}*'
|
|
64
|
+
|
|
65
|
+
if fnmatch.fnmatch(ref, branch):
|
|
66
|
+
return True
|
|
67
|
+
elif branch in ref:
|
|
68
|
+
return True
|
|
69
|
+
|
|
70
|
+
return False
|
|
71
|
+
|
|
72
|
+
return True
|
|
73
|
+
|
|
74
|
+
################################################################################
|
|
75
|
+
|
|
76
|
+
def get_matching_branches(args):
|
|
77
|
+
""" Get a list of branches matching those specified in the script arguments """
|
|
78
|
+
|
|
79
|
+
# Get the SHA1, date, author and name of the tip commit on each branch, including remotes
|
|
80
|
+
# and keep track of the maximum length of each field
|
|
81
|
+
|
|
82
|
+
branches = []
|
|
83
|
+
|
|
84
|
+
for ref in git.ref(sort='-committerdate', fields=('objectname:short', 'committerdate', 'authorname', 'refname:short'), remotes=args.all):
|
|
85
|
+
if branch_match(ref[3], args.branches):
|
|
86
|
+
branches.append(ref)
|
|
87
|
+
|
|
88
|
+
return branches
|
|
89
|
+
|
|
90
|
+
################################################################################
|
|
91
|
+
|
|
92
|
+
def list_branches(branches):
|
|
93
|
+
""" List branches. """
|
|
94
|
+
|
|
95
|
+
max_len = [0] * len(branches[0])
|
|
96
|
+
|
|
97
|
+
user = git.config_get('user', 'name')
|
|
98
|
+
|
|
99
|
+
# Output the fields in columns, highlighting user's own branches and those owned by Jenkins
|
|
100
|
+
# Replacing references to today and yesterday's dates with 'today' and 'yesterday' and
|
|
101
|
+
# reformatting dates and time for readability.
|
|
102
|
+
|
|
103
|
+
today = datetime.date.today()
|
|
104
|
+
yesterday = today - relativedelta(days=1)
|
|
105
|
+
|
|
106
|
+
all_output = []
|
|
107
|
+
|
|
108
|
+
current_branch = git.branch()
|
|
109
|
+
|
|
110
|
+
for branch in branches:
|
|
111
|
+
output = []
|
|
112
|
+
|
|
113
|
+
for i, field in enumerate(branch):
|
|
114
|
+
if i == 1:
|
|
115
|
+
field = parse(field)
|
|
116
|
+
time_str = field.strftime('%H:%M:%S')
|
|
117
|
+
|
|
118
|
+
if field.date() == today:
|
|
119
|
+
field = 'today ' + time_str
|
|
120
|
+
elif field.date() == yesterday:
|
|
121
|
+
field = 'yesterday ' + time_str
|
|
122
|
+
else:
|
|
123
|
+
field = field.date().strftime('%d/%m/%Y') + ' ' + time_str
|
|
124
|
+
|
|
125
|
+
output.append('%-*s' % (max_len[i], field))
|
|
126
|
+
max_len[i] = max(max_len[i], len(field))
|
|
127
|
+
|
|
128
|
+
highlight = 'GREEN' if branch[3] in ('master', 'main', 'develop') \
|
|
129
|
+
else 'BOLD' if branch[3] == current_branch \
|
|
130
|
+
else 'BLUE' if branch[2] == user \
|
|
131
|
+
else 'NORMAL'
|
|
132
|
+
|
|
133
|
+
all_output.append({'highlight': highlight, 'output': output})
|
|
134
|
+
|
|
135
|
+
for output in all_output:
|
|
136
|
+
line = []
|
|
137
|
+
for i, field in enumerate(output['output']):
|
|
138
|
+
line.append('%-*s' % (max_len[i], field))
|
|
139
|
+
|
|
140
|
+
colour.write('[%s:%s]' % (output['highlight'], ' '.join(line).rstrip()))
|
|
141
|
+
|
|
142
|
+
################################################################################
|
|
143
|
+
|
|
144
|
+
def delete_branches(branches):
|
|
145
|
+
""" Delete matching branches. Report an error if no branches specified """
|
|
146
|
+
|
|
147
|
+
if not branches:
|
|
148
|
+
print('ERROR: The branches to delete must be specified')
|
|
149
|
+
sys.exit(1)
|
|
150
|
+
|
|
151
|
+
print('TODO: Deleting %s' % branches)
|
|
152
|
+
|
|
153
|
+
# TODO: List branches, prompt user, delete each branch - if current branch then checkout develop, main or master first
|
|
154
|
+
|
|
155
|
+
################################################################################
|
|
156
|
+
|
|
157
|
+
def main():
|
|
158
|
+
""" Main function """
|
|
159
|
+
|
|
160
|
+
args = parse_command_line()
|
|
161
|
+
|
|
162
|
+
branches = get_matching_branches(args)
|
|
163
|
+
|
|
164
|
+
if args.delete:
|
|
165
|
+
delete_branches(branches)
|
|
166
|
+
else:
|
|
167
|
+
list_branches(branches)
|
|
168
|
+
|
|
169
|
+
################################################################################
|
|
170
|
+
|
|
171
|
+
def git_br():
|
|
172
|
+
"""Entry point"""
|
|
173
|
+
|
|
174
|
+
try:
|
|
175
|
+
main()
|
|
176
|
+
except KeyboardInterrupt:
|
|
177
|
+
sys.exit(1)
|
|
178
|
+
except BrokenPipeError:
|
|
179
|
+
sys.exit(2)
|
|
180
|
+
except git.GitError as exc:
|
|
181
|
+
colour.error(exc.msg, status=exc.status, prefix=True)
|
|
182
|
+
|
|
183
|
+
################################################################################
|
|
184
|
+
|
|
185
|
+
if __name__ == '__main__':
|
|
186
|
+
git_br()
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
#! /usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
################################################################################
|
|
4
|
+
""" Thingy "git-ca" command - an intelligent version of "git commit --amend"
|
|
5
|
+
|
|
6
|
+
Copyright (C) 2017-18 John Skilleter
|
|
7
|
+
|
|
8
|
+
Licence: GPL v3 or later
|
|
9
|
+
|
|
10
|
+
TODO: Handle attempt to amend commit in newly-initialised repo with no commits in.
|
|
11
|
+
TODO: Fix failure with "fatal: pathspec "FILENAME" did not match any files" whilst amending a commit to include a deleted file.
|
|
12
|
+
"""
|
|
13
|
+
################################################################################
|
|
14
|
+
|
|
15
|
+
import os
|
|
16
|
+
import argparse
|
|
17
|
+
import sys
|
|
18
|
+
import logging
|
|
19
|
+
|
|
20
|
+
from skilleter_modules import colour
|
|
21
|
+
from skilleter_modules import git
|
|
22
|
+
|
|
23
|
+
################################################################################
|
|
24
|
+
|
|
25
|
+
def main():
|
|
26
|
+
""" Amend a comment, updating modified files that are already committed and
|
|
27
|
+
adding files that are listed on the command line """
|
|
28
|
+
|
|
29
|
+
# Files to add to git before committing and files to commit
|
|
30
|
+
|
|
31
|
+
files_to_add = []
|
|
32
|
+
files_to_commit = []
|
|
33
|
+
|
|
34
|
+
# Parse the command line
|
|
35
|
+
|
|
36
|
+
parser = argparse.ArgumentParser(
|
|
37
|
+
description='Amend changes to the current commit. Updates files that are already in the commit and, optionally, adds additional files.')
|
|
38
|
+
|
|
39
|
+
parser.add_argument('--added', '-A', action='store_true', help='Update files in the current commit, including files added with "git add"')
|
|
40
|
+
parser.add_argument('--all', '-a', action='store_true', help='Append all locally-modified, tracked files to the current commit')
|
|
41
|
+
parser.add_argument('--everything', '-e', action='store_true', help='Append all modified and untracked files to the current commit (implies --all)')
|
|
42
|
+
parser.add_argument('--ignored', '-i', action='store_true', dest='ignored', help='Include files normally hidden by .gitignore')
|
|
43
|
+
parser.add_argument('--patch', '-p', action='store_true', help='Use the interactive patch selection interface to chose which changes to commit.')
|
|
44
|
+
parser.add_argument('--verbose', '-v', action='store_true', help='Verbose mode')
|
|
45
|
+
parser.add_argument('--dry-run', '-D', action='store_true', help='Dry-run')
|
|
46
|
+
parser.add_argument('--path', '-C', nargs=1, type=str, default=None,
|
|
47
|
+
help='Run the command in the specified directory')
|
|
48
|
+
|
|
49
|
+
parser.add_argument('files', nargs='*', help='List of files to add to the commit')
|
|
50
|
+
|
|
51
|
+
args = parser.parse_args()
|
|
52
|
+
|
|
53
|
+
# Configure logger
|
|
54
|
+
|
|
55
|
+
if args.verbose:
|
|
56
|
+
logging.basicConfig(level=logging.INFO)
|
|
57
|
+
logging.info('Debug logging enabled')
|
|
58
|
+
|
|
59
|
+
# Change directory, if specified
|
|
60
|
+
|
|
61
|
+
if args.path:
|
|
62
|
+
os.chdir(args.path[0])
|
|
63
|
+
|
|
64
|
+
# 'Add' implies 'all'
|
|
65
|
+
|
|
66
|
+
if args.everything:
|
|
67
|
+
args.all = True
|
|
68
|
+
|
|
69
|
+
# If there are any files on the command line then add them
|
|
70
|
+
# to the list of files to be committed
|
|
71
|
+
|
|
72
|
+
if args.files:
|
|
73
|
+
for filename in args.files:
|
|
74
|
+
rel_path = git.tree_path(filename)
|
|
75
|
+
files_to_add.append(rel_path)
|
|
76
|
+
|
|
77
|
+
# Move to the working tree
|
|
78
|
+
|
|
79
|
+
working_tree = git.working_tree()
|
|
80
|
+
|
|
81
|
+
if not working_tree:
|
|
82
|
+
colour.error('fatal: not a git repository (or any of the parent directories)')
|
|
83
|
+
|
|
84
|
+
os.chdir(working_tree)
|
|
85
|
+
|
|
86
|
+
# Get the list of files modified in the most recent commit
|
|
87
|
+
|
|
88
|
+
current_commit = git.commit_changes()
|
|
89
|
+
|
|
90
|
+
# Get the list of locally-modified and untracked files, including
|
|
91
|
+
# files matching .gitignore, if necessary
|
|
92
|
+
|
|
93
|
+
logging.info('Getting list of changed files')
|
|
94
|
+
local_changes = git.status_info(args.ignored)
|
|
95
|
+
|
|
96
|
+
for change in local_changes:
|
|
97
|
+
logging.info('Changed: %s (%s)', change, local_changes[change])
|
|
98
|
+
|
|
99
|
+
if change in current_commit or (args.added and local_changes[change][0] == 'A'):
|
|
100
|
+
# Locally changed and already in the commit or, optionally, added to it, so update it
|
|
101
|
+
|
|
102
|
+
files_to_commit.append(change)
|
|
103
|
+
|
|
104
|
+
elif args.all and (local_changes[change][1] in ('M', 'A', 'D', 'T') or local_changes[change][0] == 'D'):
|
|
105
|
+
# Tracked and 'all' option specified so add it to the commit
|
|
106
|
+
|
|
107
|
+
files_to_commit.append(change)
|
|
108
|
+
|
|
109
|
+
elif args.everything and local_changes[change][0] in ('!', '?'):
|
|
110
|
+
# Untracked and 'add' option specified so add it to Git and the commit
|
|
111
|
+
|
|
112
|
+
files_to_add.append(change)
|
|
113
|
+
|
|
114
|
+
if files_to_add:
|
|
115
|
+
try:
|
|
116
|
+
git.add(files_to_add)
|
|
117
|
+
except git.GitError as exc:
|
|
118
|
+
colour.error(exc.msg, status=exc.status)
|
|
119
|
+
|
|
120
|
+
files_to_commit += files_to_add
|
|
121
|
+
|
|
122
|
+
# Perform the commit running in the foreground in case the user is using a console
|
|
123
|
+
# mode text editor for commit comments.
|
|
124
|
+
|
|
125
|
+
logging.info('Files to commit: %s', files_to_commit)
|
|
126
|
+
|
|
127
|
+
try:
|
|
128
|
+
git.commit(files_to_commit, amend=True, foreground=True, patch=args.patch, dry_run=args.dry_run)
|
|
129
|
+
except git.GitError as exc:
|
|
130
|
+
sys.exit(exc.status)
|
|
131
|
+
|
|
132
|
+
################################################################################
|
|
133
|
+
|
|
134
|
+
def git_ca():
|
|
135
|
+
"""Entry point"""
|
|
136
|
+
|
|
137
|
+
try:
|
|
138
|
+
main()
|
|
139
|
+
except KeyboardInterrupt:
|
|
140
|
+
sys.exit(1)
|
|
141
|
+
except BrokenPipeError:
|
|
142
|
+
sys.exit(2)
|
|
143
|
+
|
|
144
|
+
################################################################################
|
|
145
|
+
|
|
146
|
+
if __name__ == '__main__':
|
|
147
|
+
git_ca()
|