@cli.command()<EOL>@click.option(<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>default=False,<EOL>is_flag=True,<EOL>help="<STR_LIT>",<EOL>)<EOL>@pass_config<EOL>def commit(config, no_verify):
repo = config.repo<EOL>active_branch = repo.active_branch<EOL>if active_branch.name == "<STR_LIT>":<EOL><INDENT>error_out(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>)<EOL><DEDENT>now = time.time()<EOL>def count_files_in_directory(directory):<EOL><INDENT>count = <NUM_LIT:0><EOL>for root, _, files in os.walk(directory):<EOL><INDENT>count += len(files)<EOL><DEDENT>return count<EOL><DEDENT>all_untracked_files = {}<EOL>for path in repo.untracked_files:<EOL><INDENT>root = path.split(os.path.sep)[<NUM_LIT:0>]<EOL>if root not in all_untracked_files:<EOL><INDENT>all_untracked_files[root] = {<EOL>"<STR_LIT>": [],<EOL>"<STR_LIT>": count_files_in_directory(root),<EOL>}<EOL><DEDENT>all_untracked_files[root]["<STR_LIT>"].append(path)<EOL><DEDENT>untracked_files = {}<EOL>for root, info in all_untracked_files.items():<EOL><INDENT>for path in info["<STR_LIT>"]:<EOL><INDENT>age = now - os.stat(path).st_mtime<EOL>if info["<STR_LIT>"] == <NUM_LIT:1>:<EOL><INDENT>path = root<EOL><DEDENT>if path in untracked_files:<EOL><INDENT>if age < untracked_files[path]:<EOL><INDENT>untracked_files[path] = age<EOL><DEDENT><DEDENT>else:<EOL><INDENT>untracked_files[path] = age<EOL><DEDENT><DEDENT><DEDENT>if untracked_files:<EOL><INDENT>ordered = sorted(untracked_files.items(), key=lambda x: x[<NUM_LIT:1>], reverse=True)<EOL>info_out("<STR_LIT>")<EOL>for path, age in ordered:<EOL><INDENT>if os.path.isdir(path):<EOL><INDENT>path = path + "<STR_LIT:/>"<EOL><DEDENT>print("<STR_LIT:\t>", path.ljust(<NUM_LIT>), humanize_seconds(age), "<STR_LIT>")<EOL><DEDENT>young_ones = [x for x in untracked_files.values() if x < <NUM_LIT> * <NUM_LIT> * <NUM_LIT:12>]<EOL>if young_ones:<EOL><INDENT>ignore = input("<STR_LIT>").lower().strip()<EOL>if ignore.lower().strip() == "<STR_LIT:n>":<EOL><INDENT>error_out(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>)<EOL>return <NUM_LIT:1><EOL><DEDENT>print("<STR_LIT>")<EOL><DEDENT><DEDENT>state = read(config.configfile)<EOL>try:<EOL><INDENT>data = load(config.configfile, active_branch.name)<EOL><DEDENT>except KeyError:<EOL><INDENT>error_out(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>)<EOL><DEDENT>print("<STR_LIT>")<EOL>msg = data["<STR_LIT:description>"]<EOL>if data.get("<STR_LIT>"):<EOL><INDENT>if is_bugzilla(data):<EOL><INDENT>msg = "<STR_LIT>".format(data["<STR_LIT>"], data["<STR_LIT:description>"])<EOL>msg = input('<STR_LIT>'.format(msg)).strip() or msg<EOL><DEDENT>elif is_github(data):<EOL><INDENT>msg = input('<STR_LIT>'.format(msg)).strip() or msg<EOL>msg += "<STR_LIT>".format(data["<STR_LIT>"])<EOL><DEDENT><DEDENT>if data["<STR_LIT>"]:<EOL><INDENT>question = '<STR_LIT>'<EOL>fixes = input(question).lower().strip()<EOL>if fixes in ("<STR_LIT:y>", "<STR_LIT:yes>"):<EOL><INDENT>if is_bugzilla(data):<EOL><INDENT>msg = "<STR_LIT>" + msg<EOL><DEDENT>elif is_github(data):<EOL><INDENT>msg = msg.replace("<STR_LIT>", "<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>raise NotImplementedError<EOL><DEDENT><DEDENT><DEDENT>index = repo.index<EOL>files_added = []<EOL>files_removed = []<EOL>for x in repo.index.diff(None):<EOL><INDENT>if x.deleted_file:<EOL><INDENT>files_removed.append(x.b_path)<EOL><DEDENT>else:<EOL><INDENT>files_added.append(x.b_path)<EOL><DEDENT><DEDENT>files_new = []<EOL>for x in repo.index.diff(repo.head.commit):<EOL><INDENT>files_new.append(x.b_path)<EOL><DEDENT>proceed = True<EOL>if not (files_added or files_removed or files_new):<EOL><INDENT>info_out("<STR_LIT>")<EOL>proceed = False<EOL>if input("<STR_LIT>").lower().strip() == "<STR_LIT:n>":<EOL><INDENT>proceed = True<EOL><DEDENT><DEDENT>if proceed:<EOL><INDENT>if not repo.is_dirty():<EOL><INDENT>error_out("<STR_LIT>")<EOL><DEDENT>if files_added:<EOL><INDENT>index.add(files_added)<EOL><DEDENT>if files_removed:<EOL><INDENT>index.remove(files_removed)<EOL><DEDENT>try:<EOL><INDENT>commit = index.commit(msg)<EOL><DEDENT>except git.exc.HookExecutionError as exception:<EOL><INDENT>if not no_verify:<EOL><INDENT>info_out(<EOL>"<STR_LIT>".format(<EOL>exception.command, exception.status<EOL>)<EOL>)<EOL>if exception.stdout:<EOL><INDENT>error_out(exception.stdout)<EOL><DEDENT>elif exception.stderr:<EOL><INDENT>error_out(exception.stderr)<EOL><DEDENT>else:<EOL><INDENT>error_out("<STR_LIT>")<EOL><DEDENT><DEDENT>else:<EOL><INDENT>commit = index.commit(msg, skip_hooks=True)<EOL><DEDENT><DEDENT>success_out("<STR_LIT>".format(commit.hexsha))<EOL><DEDENT>if not state.get("<STR_LIT>"):<EOL><INDENT>info_out("<STR_LIT>")<EOL>return <NUM_LIT:0><EOL><DEDENT>try:<EOL><INDENT>repo.remotes[state["<STR_LIT>"]]<EOL><DEDENT>except IndexError:<EOL><INDENT>error_out("<STR_LIT>".format(state["<STR_LIT>"]))<EOL><DEDENT>push_for_you = (<EOL>input("<STR_LIT>".format(state["<STR_LIT>"])).lower().strip()<EOL>)<EOL>if push_for_you not in ("<STR_LIT:n>", "<STR_LIT>"):<EOL><INDENT>destination = repo.remotes[state["<STR_LIT>"]]<EOL>pushed, = destination.push()<EOL>if (<EOL>pushed.flags & git.remote.PushInfo.REJECTED<EOL>or pushed.flags & git.remote.PushInfo.REMOTE_REJECTED<EOL>):<EOL><INDENT>error_out('<STR_LIT>'.format(pushed.summary), False)<EOL>try_force_push = input("<STR_LIT>").lower().strip()<EOL>if try_force_push not in ("<STR_LIT>", "<STR_LIT:n>"):<EOL><INDENT>pushed, = destination.push(force=True)<EOL>info_out(pushed.summary)<EOL><DEDENT>else:<EOL><INDENT>return <NUM_LIT:0><EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>return <NUM_LIT:0><EOL><DEDENT>if not state.get("<STR_LIT>"):<EOL><INDENT>if config.verbose:<EOL><INDENT>info_out(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>)<EOL><DEDENT>return <NUM_LIT:0><EOL><DEDENT>origin = repo.remotes[state.get("<STR_LIT>", "<STR_LIT>")]<EOL>rest = re.split(r"<STR_LIT>", origin.url)[<NUM_LIT:1>]<EOL>org, repo = rest.split("<STR_LIT>")[<NUM_LIT:0>].split("<STR_LIT:/>", <NUM_LIT:1>)<EOL>search = {<EOL>"<STR_LIT>": "<STR_LIT>".format(state["<STR_LIT>"], active_branch.name),<EOL>"<STR_LIT:state>": "<STR_LIT>",<EOL>}<EOL>for pull_request in github.find_pull_requests(config, org, repo, **search):<EOL><INDENT>print("<STR_LIT>")<EOL>print("<STR_LIT>")<EOL>print("<STR_LIT:\t>", pull_request["<STR_LIT>"])<EOL>break<EOL><DEDENT>else:<EOL><INDENT>github_url = "<STR_LIT>"<EOL>github_url = github_url.format(<EOL>org, repo, org, "<STR_LIT>", state["<STR_LIT>"], active_branch.name<EOL>)<EOL>print("<STR_LIT>")<EOL>print("<STR_LIT>")<EOL>success_out(github_url)<EOL><DEDENT>print("<STR_LIT>")<EOL>return <NUM_LIT:0><EOL>
Commit the current branch with all files.