#!/bin/bash
# g3 - git distributed VCS helper

set -e

source '/home/zwelch/src/mcf/mcsh-release/install/share/mcsh/mcsh.sh'

lib_load 'sys/tool/git'


######
# Check

g3_config_init() {
	script_setting_vars -ro g3_gitdir
	g3_gitdir=$script_datadir/git

	script_setting_vars -ro g3_status_default
	g3_status_default=repo
}

g3_config_check() {
	:
}

######
# Working Copy CLI

g3_status() {
	if [ "$*" ]; then
		cmd_dispatch "$@"
	else
		git_status_${g3_status_default}
	fi
}

g3_status_usage() {
	cat <<USAGE
...
Git Status Commands
	new				Shows tracked and untracked
	repo				Shows only tracked files (default)
	all				Shows all files (untracked and ignored)
USAGE
}

g3_status_new() { git_status_tracked normal "$@"; }
g3_status_repo() { git_status_tracked no "$@"; }
g3_status_all() { git_status_tracked all "$@"; }


######
# Index CLI

g3_index() { cmd_dispatch "$@"; }
g3_index_usage() {
	cat <<USAGE
...
Git Staging Commands:
	reset				Resets the index but retains changes
	nuke				Resets the index and drops changes
USAGE
}
g3_index_reset() { git_reset --soft HEAD "$@"; }
g3_index_nuke() { git_reset --hard HEAD "$@"; }


######
# Commit CLI

g3_commit() {
	if [ "$*" ]; then
		cmd_dispatch "$@"
	else
		git_commit_index
	fi
}

g3_commit_usage() {
	cat <<USAGE
...
Git Commit Creation:
	index 				Commit only staged files
	fast [<path>+]			Adds all tracked files and commits
	all [<path>+]			Adds tracked and untracked files

Git Commit Destruction:
	drop [<count>]			Drops some numer of commits (rollback)
USAGE
# TODO	wizard [<path>+]		Commits using guided process
# TODO	auto [<path>+]			Automatic commit process
# TODO	custom [<path>+]		Custom commit process
}

g3_commit_index() { git_commit_index; }
g3_commit_fast() { git_commit_fast "$@"; }
g3_commit_all() { git_commit_all "$@"; }
g3_commit_drop() { git_commit_drop "$@"; }


######
# Check

g3_check() {
	local git_repodir=$cmd_tempdir
	run_pushd "$cmd_tempdir"
	git_init test "A sample git repository"
	git_repo_pushd test
	run popd
}


######
# Main

g3_desc() { echo "git helper"; }
g3_usage() {
	cat <<USAGE
<cmd> ...
Git Commands:
	status ...			Reports working copy status
	index ...			Manages indexes of
	commit ...			Commits changes of
USAGE
}
g3_help() {
	cat <<HELP
g3 is a git helper tool.  It is part of the mcsh package.
HELP
}

app_run "$@"

View the Developer Guide Index

View the Reference Manual Index


Generated on Thu May 4 18:59:07 PDT 2017 by mcsh i7 v0.19.0.