Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
O
oh-my-fish
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
oh-my-fish
Commits
a1db5d52
Commit
a1db5d52
authored
Oct 24, 2015
by
Derek Stavis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
omf.repo.pull: Don't repeat yourself treatment
parent
f95d1848
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
20 deletions
+32
-20
pkg/omf/cli/omf.repo.pull.fish
pkg/omf/cli/omf.repo.pull.fish
+32
-20
No files found.
pkg/omf/cli/omf.repo.pull.fish
View file @
a1db5d52
function omf.repo.pull
function omf.repo.pull
if test (count $argv) -eq 0
if test (count $argv) -eq 0
echo (omf::err)"Argument of omf.repo.pull is the repo path."(omf::off)
echo (omf::err)"Argument of omf.repo.pull is the repo path."(omf::off)
return $OMF_MISSING_ARG
return $OMF_MISSING_ARG
end
end
set -l repo_dir $argv[1]
set -l repo_dir $argv[1]
if test (command git --git-dir "$repo_dir"/.git --work-tree "$repo_dir" config --get remote.upstream.url)
function omf.repo.git -V repo_dir
set repository upstream
command git --git-dir "$repo_dir"/.git --work-tree "$repo_dir" $argv
else
set repository origin
end
end
set initial_branch (command git --git-dir "$repo_dir"/.git --work-tree "$repo_dir" symbolic-ref -q --short HEAD); or return $OMF_UNKNOWN_ERR
function omf.repo.git.stash -V repo_dir
set initial_revision (command git --git-dir "$repo_dir"/.git --work-tree "$repo_dir" rev-parse -q --verify HEAD); or return $OMF_UNKNOWN_ERR
command git -C "$repo_dir" stash $argv
end
if not command git --git-dir "$repo_dir"/.git --work-tree "$repo_dir" diff --quiet
set -l remote origin
echo (omf::em)"Stashing your changes:"(omf::off)
if test (omf.repo.git config --get remote.upstream.url)
command git -C "$repo_dir" status --short --untracked-files
set remote upstream
end
set initial_branch (omf.repo.git symbolic-ref -q --short HEAD);
or return $OMF_UNKNOWN_ERR
set initial_revision (omf.repo.git rev-parse -q --verify HEAD);
or return $OMF_UNKNOWN_ERR
command git -C "$repo_dir" stash save --include-untracked --quiet
if not omf.repo.git diff --quiet
set stashed
echo (omf::em)"Stashing your changes:"(omf::off)
omf.repo.git status --short --untracked-files
omf.repo.git.stash save --include-untracked --quiet;
and set stashed
end
end
if test "$initial_branch" != master
if test "$initial_branch" != master
command git --git-dir "$repo_dir"/.git --work-tree "$repo_dir"
checkout master --quiet
omf.repo.git
checkout master --quiet
end
end
# the refspec ensures that '$repository/master' gets updated
set -l refspec "refs/heads/master:refs/remotes/$remote/master"
command git --git-dir "$repo_dir"/.git --work-tree "$repo_dir" pull --rebase --quiet $repository "refs/heads/master:refs/remotes/$repository/master"
if test $status -eq 2 #SIGINT
# the refspec ensures that '$remote/master' gets updated
command git --git-dir "$repo_dir"/.git --work-tree "$repo_dir" checkout $initial_branch
if not omf.repo.git pull --ff-only --quiet $remote $refspec
command git --git-dir "$repo_dir"/.git --work-tree "$repo_dir" reset --hard $initial_revision
omf.repo.git checkout $initial_branch
set -q stashed; and command git -C "$repo_dir" stash pop
omf.repo.git reset --hard $initial_revision
set -q stashed; and omf.repo.git.stash pop
end
end
if test "$initial_branch" != master
if test "$initial_branch" != master
command git --git-dir "$repo_dir"/.git --work-tree "$repo_dir"
checkout $initial_branch --quiet
omf.repo.git
checkout $initial_branch --quiet
end
end
if set -q stashed
if set -q stashed
command git -C "$repo_dir"
stash pop --quiet
omf.repo.git.
stash pop --quiet
echo (omf::em)"Restored your changes:"(omf::off)
echo (omf::em)"Restored your changes:"(omf::off)
command git -C "$repo_dir" status --short --untracked-files
command git -C "$repo_dir" status --short --untracked-files
end
end
functions -e omf.repo.git{,.stash}
return 0
return 0
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment