Skip to content

Commit 34e8a7f

Browse files
committed
🔨 code refactoring on magic labels
1 parent 98f1c0a commit 34e8a7f

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@
5959
# Add any paths that contain custom static files (such as style sheets) here,
6060
# relative to this directory. They are copied after the builtin static files,
6161
# so a file named "default.css" will overwrite the builtin "default.css".
62-
html_static_path = ['static']
62+
html_static_path = ['static']

gitfs2/constants.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
PROGRAM_NAME = "gitfs2"
22
REPOS_DIR_NAME = "repos"
33

4-
MESSAGE_INVALID_GIT_URL = 'An invalid git url: "%s" in mobanfile'
4+
MESSAGE_INVALID_GIT_URL_FMT = 'An invalid git url: "%s" in mobanfile'
5+
MESSAGE_GIT_COMMAND_PROBLEM = "Unable to run git commands. Offline?"
6+
MESSAGE_FOUND_REPO_FMT = "Found local checkout in %s"
7+
MESSAGE_UPDATE_SUBMODULE = "updating submodule"
8+
MESSAGE_CHECKOUT_SUBMODULE = "checking out submodule"
9+
MESSAGE_GIT_CLONE_FMT = "git clone %s"
510
DEFAULT_CLONE_DEPTH = 2

gitfs2/repo.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,26 +69,26 @@ def git_clone(require, action_required=True):
6969
if action_required:
7070
try:
7171
fs.open_fs(local_repo_folder)
72-
reporter.info("Found repo in %s" % local_repo_folder)
72+
reporter.info(constants.MESSAGE_FOUND_REPO_FMT % local_repo_folder)
7373
repo = Repo(local_repo_folder)
7474
repo.git.pull()
7575
if require.reference:
7676
repo.git.checkout(require.reference)
7777
elif require.branch:
7878
repo.git.checkout(require.branch)
7979
if require.submodule:
80-
reporter.info("updating submodule")
80+
reporter.info(constants.MESSAGE_UPDATE_SUBMODULE)
8181
repo.git.submodule("update")
8282
except fs.errors.CreateFailed:
83-
reporter.info("git clone %s" % require.git_url)
83+
reporter.info(constants.MESSAGE_GIT_CLONE_FMT % require.git_url)
8484
repo = Repo.clone_from(
8585
require.git_url, local_repo_folder, **require.clone_params()
8686
)
8787
if require.submodule:
88-
reporter.info("checking out submodule")
88+
reporter.info(constants.MESSAGE_CHECKOUT_SUBMODULE)
8989
repo.git.submodule("update", "--init")
9090
except GitCommandError as e:
91-
reporter.warn("Unable to run git commands. Offline?")
91+
reporter.warn(constants.MESSAGE_GIT_COMMAND_PROBLEM)
9292
LOG.warn(e)
9393
return local_repo_folder
9494

@@ -103,7 +103,7 @@ def get_repo_name(repo_url):
103103
repo = giturlparse.parse(repo_url.rstrip("/"))
104104
return repo.name
105105
except ParserError:
106-
reporter.error(constants.MESSAGE_INVALID_GIT_URL % repo_url)
106+
reporter.error(constants.MESSAGE_INVALID_GIT_URL_FMT % repo_url)
107107
raise
108108

109109

0 commit comments

Comments
 (0)