Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
open-source
hggitforge
Commits
39a79e13521d
Commit
a7b1ceb8
authored
Oct 13, 2020
by
Elouan Martinet
Browse files
Catch exceptions and display errors when needed
parent
80595e0b7385
Changes
1
Hide whitespace changes
Inline
Side-by-side
hggithub.py
View file @
39a79e13
...
...
@@ -70,16 +70,7 @@ def _ghclone(path_url, destination):
update_hgrc
(
destination
)
@
command
(
"ghclone"
,
[],
_
(
"git_path working_directory"
),
norepo
=
True
)
def
ghclone
(
ui
,
git_url
,
working_directory
,
**
opts
):
"""Prepare working directory to work with github"""
_ghclone
(
git_url
,
working_directory
)
@
command
(
"ghpull"
,
[],
_
(
""
))
def
ghpull
(
ui
,
repo
,
**
opts
):
"""Prepare working directory to work with github"""
git_repo
=
ui
.
config
(
"gitrepo"
,
"gitrepo"
)
def
_ghpull
(
git_repo
):
cmd
(
"Fetching remote Git repository"
,
[
"git"
,
"fetch"
,
"-q"
,
"origin"
,
"master:master"
],
...
...
@@ -89,12 +80,10 @@ def ghpull(ui, repo, **opts):
cmd
(
"Publishing master bookmark"
,
[
"hg"
,
"phase"
,
"-p"
,
"master"
])
@
command
(
"ghpush"
,
[],
_
(
"bookmark"
))
def
ghpush
(
ui
,
repo
,
bookmark
,
**
opts
):
"""Prepare working directory to work with github"""
git_repo
=
ui
.
config
(
"gitrepo"
,
"gitrepo"
)
def
_ghpush
(
git_repo
,
bookmark
):
cmd
(
"Pushing bookmark to local Git repository"
,
[
"hg"
,
"push"
,
"-B"
,
bookmark
,
"-f"
]
"Pushing bookmark to local Git repository"
,
[
"hg"
,
"push"
,
"-B"
,
bookmark
,
"-f"
],
)
# TODO use --force-with-lease if possible
cmd
(
...
...
@@ -102,3 +91,34 @@ def ghpush(ui, repo, bookmark, **opts):
[
"git"
,
"push"
,
"--set-upstream"
,
"origin"
,
bookmark
,
"-f"
],
cwd
=
git_repo
,
)
@
command
(
"ghclone"
,
[],
_
(
"git_path working_directory"
),
norepo
=
True
)
def
ghclone
(
ui
,
git_url
,
working_directory
,
**
opts
):
"""Prepare working directory to work with github"""
try
:
_ghclone
(
git_url
,
working_directory
)
except
CalledProcessError
:
pass
except
ValueError
as
ex
:
print
(
ex
)
@
command
(
"ghpull"
,
[],
_
(
""
))
def
ghpull
(
ui
,
repo
,
**
opts
):
"""Prepare working directory to work with github"""
git_repo
=
ui
.
config
(
"gitrepo"
,
"gitrepo"
)
try
:
_ghpull
(
git_repo
)
except
CalledProcessError
:
pass
@
command
(
"ghpush"
,
[],
_
(
"bookmark"
))
def
ghpush
(
ui
,
repo
,
bookmark
,
**
opts
):
"""Prepare working directory to work with github"""
git_repo
=
ui
.
config
(
"gitrepo"
,
"gitrepo"
)
try
:
_ghpush
(
git_repo
,
bookmark
)
except
CalledProcessError
:
pass
Write
Preview
Supports
Markdown
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