Skip to content

Feature/reset #489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions lib/git-subrepo
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ git subrepo <command> <arguments> <options>
Commands:
clone Clone a remote repository into a local subdirectory
init Turn a current subdirectory into a subrepo
reset Reset subrepo performing a forced reclone
pull Pull upstream changes to the subrepo
push Push local subrepo changes upstream

Expand Down Expand Up @@ -178,6 +179,19 @@ main() {
# info to the user.
#------------------------------------------------------------------------------

command:reset() {
command-setup +subdir forced_commit

local reclone_up_to_date=false
local force_wanted=true
if [ -n "$forced_commit" ]; then
forced_commit="$(git rev-parse "$forced_commit")"
fi

subrepo:clone
say "Subrepo '$subdir' reset to '$subrepo_remote' ($subrepo_branch)."
}

# `git subrepo clone <url> [<subdir>]` command:
command:clone() {
command-setup +subrepo_remote subdir:guess-subdir
Expand Down Expand Up @@ -470,6 +484,9 @@ subrepo:clone() {
if $force_wanted; then
o "--force indicates a reclone."
CALL subrepo:fetch
if [ -n "$forced_commit" ]; then
upstream_head_commit=$forced_commit
fi
read-gitrepo-file
o "Check if we already are up to date."
if [[ $upstream_head_commit == $subrepo_commit ]]; then
Expand Down Expand Up @@ -1077,6 +1094,7 @@ get-command-options() {
}

options_help='all'
options_reset='branch remote'
options_branch='all fetch force'
options_clean='ALL all force'
options_clone='branch edit force message method'
Expand Down