Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6d0c8c0

Browse files
committed
Merge pull request #69 from dl1ely/master
Nicer handling of missing sections in .git/ftpdata file
2 parents 87055ff + 3265c38 commit 6d0c8c0

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

git-ftp.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ class FtpDataOldVersion(Exception):
6363
class FtpSslNotSupported(Exception):
6464
pass
6565

66+
class SectionNotFound(Exception):
67+
pass
68+
6669
def main():
6770
Git.git_binary = 'git' # Windows doesn't like env
6871

@@ -196,9 +199,14 @@ def get_ftp_creds(repo, options):
196199
logging.info("Using .git/ftpdata")
197200
cfg.read(ftpdata)
198201

199-
if (not cfg.has_section(options.section)) and cfg.has_section('ftp'):
200-
raise FtpDataOldVersion("Please rename the [ftp] section to [branch]. " +
201-
"Take a look at the README for more information")
202+
if (not cfg.has_section(options.section)):
203+
if cfg.has_section('ftp'):
204+
raise FtpDataOldVersion("Please rename the [ftp] section to [branch]. " +
205+
"Take a look at the README for more information")
206+
else:
207+
raise SectionNotFound("Your .git/ftpdata file does not contain a section " +
208+
"named '%s'" % options.section)
209+
202210

203211
# just in case you do not want to store your ftp password.
204212
try:

0 commit comments

Comments
 (0)