patman: Various fixes
cover patman: Various fixes
This fixes the location of patman config file from ~/.config/patman to ~/.patman. Also addresses the creation of new config file when it isn't present.
Vikram Narayanan (2):
patman: Change the location of patman config file
patman: Handle creation of patman config file
tools/patman/README | 5 ++++- tools/patman/gitutil.py | 18 ++++++++++++++++++ tools/patman/settings.py | 39 +++++++++++++++++++++++++++++++++++---- 3 files changed, 57 insertions(+), 5 deletions(-)
Signature · 1 line
1.7.4.1
PATCH 1/2 patman: Change the location of patman config file
Move the config file from ~/.config/patman to ~/.patman as it is more appropriate to have it there. Update the same in the README.
--- tools/patman/README | 2 +- tools/patman/settings.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
tools/patman/README +1 -1
@@ -68,7 +68,7 @@ How to configure it For most cases patman will locate and use the file 'doc/git-mailrc' in your U-Boot directory. This contains most of the aliases you will need. -To add your own, create a file ~/.config/patman directory like this: +To add your own, create a file ~/.patman like this: >>>> # patman alias file
tools/patman/settings.py +1 -1
@@ -69,7 +69,7 @@ def Setup(config_fname=''): """ settings = ConfigParser.SafeConfigParser() if config_fname == '': - config_fname = '%s/.config/patman' % os.getenv('HOME') + config_fname = '%s/.patman' % os.getenv('HOME') if config_fname: settings.read(config_fname)
Signature · 1 line
1.7.4.1
PATCH 1/2 patman: Change the location of patman config file
Quoted 7 lines · Vikram Narayanan
Move the config file from ~/.config/patman to ~/.patman as it is more appropriate to have it there. Update the same in the README.
Signed-off-by Vikram Narayanan <[email protected]>Cc Simon Glass <[email protected]>Cc Wolfgang Denk <[email protected]>
Quoted 36 lines
--- tools/patman/README | 2 +- tools/patman/settings.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)tools/patman/README +1
-1@@ -68,7 +68,7 @@ How to configure it For most cases patman will locate and use the file 'doc/git-mailrc' in your U-Boot directory. This contains most of the aliases you will need. -To add your own, create a file ~/.config/patman directory like this: +To add your own, create a file ~/.patman like this: >>>> # patman alias filetools/patman/settings.py +1
-2@@ -69,7 +69,7 @@ def Setup(config_fname=''): """ settings = ConfigParser.SafeConfigParser() if config_fname == '': - config_fname = '%s/.config/patman' % os.getenv('HOME') + config_fname = '%s/.patman' % os.getenv('HOME') if config_fname: settings.read(config_fname) --1.7.4.1
PATCH 1/2 patman: Change the location of patman config file
Hello Wolfgang,
Quoted 8 lines · Simon Glass
On Wed, May 23, 2012 at 11:58 AM, Vikram Narayanan <[email protected] <mailto:[email protected]>> wrote:
Move the config file from ~/.config/patman to ~/.patman as it is more appropriate to have it there. Update the same in the README.
Quoted 7 lines
Signed-off-by Vikram Narayanan <[email protected]<mailto:[email protected]>>
Cc: Simon Glass <sjg at chromium.org <mailto:[email protected]>>
Cc: Wolfgang Denk <wd at denx.de <mailto:[email protected]>>Acked-by Simon Glass <sjg at chromium.org <mailto:[email protected]>>
Can you please consider this patch series? Both are acked by Simon. If you have any issues in taking this in, please let me know.
Thanks,
Vikram
Quoted 37 lines
---
tools/patman/README | 2 +-
tools/patman/settings.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/patman/README b/tools/patman/README
index 7ba9e80..1af8665 100644
--- a/tools/patman/README
+++ b/tools/patman/README
@@ -68,7 +68,7 @@ How to configure it
For most cases patman will locate and use the file 'doc/git-mailrc' in
your U-Boot directory. This contains most of the aliases you will
need.
-To add your own, create a file ~/.config/patman directory like this:
+To add your own, create a file ~/.patman like this:
>>>>
# patman alias file
diff --git a/tools/patman/settings.py b/tools/patman/settings.py
index 049c709..f980071 100644
--- a/tools/patman/settings.py
+++ b/tools/patman/settings.py
@@ -69,7 +69,7 @@ def Setup(config_fname=''):
"""
settings = ConfigParser.SafeConfigParser()
if config_fname == '':
- config_fname = '%s/.config/patman' % os.getenv('HOME')
+ config_fname = '%s/.patman' % os.getenv('HOME')
if config_fname:
settings.read(config_fname)
--
1.7.4.1Wolfgang Denk
AppliedPATCH 1/2 patman: Change the location of patman config file
In reply to Vikram NarayananDear Vikram Narayanan,
Quoted 10 lines · In message <[email protected]> you wrote:
Move the config file from ~/.config/patman to ~/.patman as it is more appropriate to have it there. Update the same in the README.
Signed-off-by Vikram Narayanan <[email protected]>Cc Simon Glass <[email protected]>Cc Wolfgang Denk <[email protected]>--- tools/patman/README | 2 +- tools/patman/settings.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
If programming was easy, they wouldn't need something as complicated
as a human being to do it, now would they?
- L. Wall & R. L. Schwartz, _Programming Perl_PATCH 2/2 patman: Handle creation of patman config file
In reply to Vikram Narayananpatman shouts when it couldn't find a $(HOME)/.patman file. Handle it in a sane way by creating a new one for the user. It looks for a user.name and user.email in the global .gitconfig file, waits for the user input if it can't find there. Update the same in the README
--- tools/patman/README | 3 +++ tools/patman/gitutil.py | 18 ++++++++++++++++++ tools/patman/settings.py | 37 ++++++++++++++++++++++++++++++++++--- 3 files changed, 55 insertions(+), 3 deletions(-)
tools/patman/README +3 -0
@@ -68,6 +68,9 @@ How to configure it For most cases patman will locate and use the file 'doc/git-mailrc' in your U-Boot directory. This contains most of the aliases you will need. +During the first run patman creates a config file for you by taking the default +user name and email address from the global .gitconfig file. + To add your own, create a file ~/.patman like this: >>>>
tools/patman/gitutil.py +18 -0
@@ -357,6 +357,24 @@ def GetAliasFile(): fname = os.path.join(GetTopLevel(), fname.strip()) return fname +def GetDefaultUserName(): + """Gets the user.name from .gitconfig file. + + Returns: + User name found in .gitconfig file, or None if none + """ + uname = command.OutputOneLine('git', 'config', '--global', 'user.name') + return uname + +def GetDefaultUserEmail(): + """Gets the user.email from the global .gitconfig file. + + Returns: + User's email found in .gitconfig file, or None if none + """ + uemail = command.OutputOneLine('git', 'config', '--global', 'user.email') + return uemail + def Setup(): """Set up git utils, by reading the alias files.""" settings.Setup('')
tools/patman/settings.py +34 -3
@@ -24,7 +24,7 @@ import os import re import command - +import gitutil def ReadGitAliases(fname): """Read a git alias file. This is in the form used by git:
@@ -61,6 +61,33 @@ def ReadGitAliases(fname): fd.close() +def CreatePatmanConfigFile(config_fname): + """Creates a config file under $(HOME)/.patman if it can't find one. + + Args: + config_fname: Default config filename i.e., $(HOME)/.patman + + Returns: + None + """ + name = gitutil.GetDefaultUserName() + if name == None: + name = raw_input("Enter name: ") + + email = gitutil.GetDefaultUserEmail() + + if email == None: + email = raw_input("Enter email: ") + + try: + f = open(config_fname, 'w') + except IOError: + print "Couldn't create patman config file\n" + raise + + print >>f, "[alias]\nme: %s <%s>" % (name, email) + f.close(); + def Setup(config_fname=''): """Set up the settings module by reading config files.
@@ -70,8 +97,12 @@ def Setup(config_fname=''): settings = ConfigParser.SafeConfigParser() if config_fname == '': config_fname = '%s/.patman' % os.getenv('HOME') - if config_fname: - settings.read(config_fname) + + if not os.path.exists(config_fname): + print "No config file found ~/.patman\nCreating one...\n" + CreatePatmanConfigFile(config_fname) + + settings.read(config_fname) for name, value in settings.items('alias'): alias[name] = value.split(',')
Signature · 1 line
1.7.4.1
Wolfgang Denk
AppliedPATCH 2/2 patman: Handle creation of patman config file
Dear Vikram Narayanan,
Quoted 10 lines · In message <[email protected]> you wrote:
patman shouts when it couldn't find a $(HOME)/.patman file. Handle it in a sane way by creating a new one for the user. It looks for a user.name and user.email in the global .gitconfig file, waits for the user input if it can't find there. Update the same in the README
Signed-off-by Vikram Narayanan <[email protected]>Acked-by Simon Glass <[email protected]>Cc Simon Glass <[email protected]>Cc Wolfgang Denk <[email protected]>
Quoted 5 lines
--- tools/patman/README | 3 +++ tools/patman/gitutil.py | 18 ++++++++++++++++++ tools/patman/settings.py | 37 ++++++++++++++++++++++++++++++++++--- 3 files changed, 55 insertions(+), 3 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de It is wrong always, everywhere and for everyone to believe anything upon insufficient evidence. - W. K. Clifford, British philosopher, circa 1876