Skip to content

Commit

Permalink
Add verbosity
Browse files Browse the repository at this point in the history
  • Loading branch information
milind-shakya-sp committed Nov 17, 2020
1 parent 88d5320 commit 76cc115
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions gitown/gitown.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def __init__(
files,
owners,
ownership_threshold=DEFAULT_OWNERSHIP_THRESHOLD,
codeowners_filename=DEFAULT_CODEOWNERS_FILE
codeowners_filename=DEFAULT_CODEOWNERS_FILE,
verbose=False
):
self.files = files,
self.original_codeowner_data = {}
Expand All @@ -27,6 +28,7 @@ def __init__(
self.owners = owners
self.ownership_threshold = ownership_threshold
self.codeowners_file = codeowners_filename
self.verbose = verbose

with open(self.codeowners_file, newline='') as csvfile:
reader = csv.reader(csvfile, delimiter=' ')
Expand Down Expand Up @@ -62,11 +64,15 @@ def update_file(self, updated_data):
csvfile.write("#\n")
csvfile.write("# Order is important. The last matching pattern has the most precedence.\n")
csvfile.write("\n")
csvfile.write("\n")
csvfile.write("# This file is also being managed automatically by the gitown tool.\n")

writer = csv.writer(csvfile, delimiter=' ', lineterminator='\n')
for key, value in updated_data.items():
writer.writerow([key] + value)
if self.verbose:
print(f"updated data: {updated_data}")
print(f"original data: {self.original_codeowner_data}")
self.updated = True

def get_committer_line_frequency_percentage(self, committer_email, filename):
Expand Down Expand Up @@ -107,10 +113,12 @@ def main():
parser.add_argument('filenames', nargs='+')
parser.add_argument('--ownership_threshold')
parser.add_argument('--codeowners_filename')
parser.add_argument('--verbose', '-v', action='count', default=0)
args = parser.parse_args()
files = args.filenames[0]
ownership_threshold = int(args.ownership_threshold or DEFAULT_OWNERSHIP_THRESHOLD)
codeowners_filename = args.codeowners_filename
verbose = bool(args.verbose)

if len(files) == 0:
parser.error('No filenames provided')
Expand All @@ -125,7 +133,8 @@ def main():
files,
owners,
ownership_threshold=ownership_threshold,
codeowners_filename=codeowners_filename or DEFAULT_CODEOWNERS_FILE
codeowners_filename=codeowners_filename or DEFAULT_CODEOWNERS_FILE,
verbose=verbose
)
codeowners.main()

Expand Down

0 comments on commit 76cc115

Please sign in to comment.