* [U-Boot] [PATCH v2 4/4] patman: Handle creation of patman config
@ 2012-04-27 16:39 Vikram Narayanan
2012-04-30 8:44 ` Wolfgang Denk
2012-04-30 17:37 ` Simon Glass
0 siblings, 2 replies; 6+ messages in thread
From: Vikram Narayanan @ 2012-04-27 16:39 UTC (permalink / raw)
To: u-boot
patman shouts when it couldn't find a $(HOME)/.config/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 those.
Signed-off-by: Vikram Narayanan <vikram186@gmail.com>
Cc: Simon Glass <sjg@chromium.org>
---
tools/patman/gitutil.py | 18 ++++++++++++++++++
tools/patman/settings.py | 34 +++++++++++++++++++++++++++++++---
2 files changed, 49 insertions(+), 3 deletions(-)
diff --git a/tools/patman/gitutil.py b/tools/patman/gitutil.py
index 48ca998..2eacb13 100644
--- a/tools/patman/gitutil.py
+++ b/tools/patman/gitutil.py
@@ -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('')
diff --git a/tools/patman/settings.py b/tools/patman/settings.py
index 049c709..03ea307 100644
--- a/tools/patman/settings.py
+++ b/tools/patman/settings.py
@@ -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,30 @@ def ReadGitAliases(fname):
fd.close()
+def CreatePatmanConfigFile(config_fname):
+ """ Creates a config file under $(HOME)/.config/ if it can't find one.
+
+ 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 +94,12 @@ def Setup(config_fname=''):
settings = ConfigParser.SafeConfigParser()
if config_fname == '':
config_fname = '%s/.config/patman' % os.getenv('HOME')
- if config_fname:
- settings.read(config_fname)
+
+ if not os.path.exists(config_fname):
+ print "No config file found under ~/.config/\nCreating one...\n"
+ CreatePatmanConfigFile(config_fname)
+
+ settings.read(config_fname)
for name, value in settings.items('alias'):
alias[name] = value.split(',')
--
1.7.4.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH v2 4/4] patman: Handle creation of patman config
2012-04-27 16:39 [U-Boot] [PATCH v2 4/4] patman: Handle creation of patman config Vikram Narayanan
@ 2012-04-30 8:44 ` Wolfgang Denk
2012-04-30 13:37 ` Vikram Narayanan
2012-04-30 17:37 ` Simon Glass
1 sibling, 1 reply; 6+ messages in thread
From: Wolfgang Denk @ 2012-04-30 8:44 UTC (permalink / raw)
To: u-boot
Dear Vikram & Simon,
In message <4F9ACBD1.1080003@gmail.com> you wrote:
>
> patman shouts when it couldn't find a $(HOME)/.config/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 those.
I have a more general question here: Why is the config file in
$(HOME)/.config/patman (instead for example $(HOME)/.patman) ?
My understanding is that $(HOME)/.config/ is defined by the XDG Base
Directory Specification - but patman has nothign to do with the X11
desktop - or has it?
Best regards,
Wolfgang Denk
--
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
Another dream that failed. There's nothing sadder.
-- Kirk, "This side of Paradise", stardate 3417.3
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH v2 4/4] patman: Handle creation of patman config
2012-04-30 8:44 ` Wolfgang Denk
@ 2012-04-30 13:37 ` Vikram Narayanan
2012-04-30 17:10 ` Simon Glass
0 siblings, 1 reply; 6+ messages in thread
From: Vikram Narayanan @ 2012-04-30 13:37 UTC (permalink / raw)
To: u-boot
Hello Wolfgang,
On 4/30/2012 2:14 PM, Wolfgang Denk wrote:
> Dear Vikram& Simon,
>
> In message<4F9ACBD1.1080003@gmail.com> you wrote:
>>
>> patman shouts when it couldn't find a $(HOME)/.config/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 those.
>
> I have a more general question here: Why is the config file in
> $(HOME)/.config/patman (instead for example $(HOME)/.patman) ?
>
> My understanding is that $(HOME)/.config/ is defined by the XDG Base
> Directory Specification - but patman has nothign to do with the X11
> desktop - or has it?
Your argument is right. But Simon is the right person for answering this
as he is the one who pushed patman.
Regards,
Vikram
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH v2 4/4] patman: Handle creation of patman config
2012-04-30 13:37 ` Vikram Narayanan
@ 2012-04-30 17:10 ` Simon Glass
0 siblings, 0 replies; 6+ messages in thread
From: Simon Glass @ 2012-04-30 17:10 UTC (permalink / raw)
To: u-boot
Hi Wolfgang, Vikram,
On Mon, Apr 30, 2012 at 6:37 AM, Vikram Narayanan <vikram186@gmail.com>wrote:
> Hello Wolfgang,
>
> On 4/30/2012 2:14 PM, Wolfgang Denk wrote:
>
>> Dear Vikram& Simon,
>>
>>
>> In message<4F9ACBD1.1080003@**gmail.com <4F9ACBD1.1080003@gmail.com>>
>> you wrote:
>>
>>>
>>> patman shouts when it couldn't find a $(HOME)/.config/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 those.
>>>
>>
>> I have a more general question here: Why is the config file in
>> $(HOME)/.config/patman (instead for example $(HOME)/.patman) ?
>>
>> My understanding is that $(HOME)/.config/ is defined by the XDG Base
>> Directory Specification - but patman has nothign to do with the X11
>> desktop - or has it?
>>
>
> Your argument is right. But Simon is the right person for answering this
> as he is the one who pushed patman.
>
I agree also, it was an attempt to reduce clutter in home but I agree that
.patman is more correct.
Vikram, let me check your series again and then would you mind inserting a
patch to change this at the start of your series?
> Regards,
> Vikram
>
Regards,
Simon
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH v2 4/4] patman: Handle creation of patman config
2012-04-27 16:39 [U-Boot] [PATCH v2 4/4] patman: Handle creation of patman config Vikram Narayanan
2012-04-30 8:44 ` Wolfgang Denk
@ 2012-04-30 17:37 ` Simon Glass
2012-05-01 3:14 ` Vikram Narayanan
1 sibling, 1 reply; 6+ messages in thread
From: Simon Glass @ 2012-04-30 17:37 UTC (permalink / raw)
To: u-boot
Hi Vikram,
On Fri, Apr 27, 2012 at 9:39 AM, Vikram Narayanan <vikram186@gmail.com>wrote:
>
> patman shouts when it couldn't find a $(HOME)/.config/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 those.
>
> Signed-off-by: Vikram Narayanan <vikram186@gmail.com>
> Cc: Simon Glass <sjg@chromium.org>
>
Acked-by: Simon Glass <sjg@chromium.org>
In terms of changing the config file to ~/.patman, this could actually be a
subsequent patch if you like. But there are a few nits below if you
re-issue.
> ---
> tools/patman/gitutil.py | 18 ++++++++++++++++++
> tools/patman/settings.py | 34 +++++++++++++++++++++++++++++++---
> 2 files changed, 49 insertions(+), 3 deletions(-)
>
> diff --git a/tools/patman/gitutil.py b/tools/patman/gitutil.py
> index 48ca998..2eacb13 100644
> --- a/tools/patman/gitutil.py
> +++ b/tools/patman/gitutil.py
> @@ -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('')
> diff --git a/tools/patman/settings.py b/tools/patman/settings.py
> index 049c709..03ea307 100644
> --- a/tools/patman/settings.py
> +++ b/tools/patman/settings.py
> @@ -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,30 @@ def ReadGitAliases(fname):
>
> fd.close()
>
> +def CreatePatmanConfigFile(config_fname):
> + """ Creates a config file under $(HOME)/.config/ if it can't find one.
>
nits: Remove space before 'Creates' and add Args: to document config_fname,
> +
> + 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 +94,12 @@ def Setup(config_fname=''):
> settings = ConfigParser.SafeConfigParser()
> if config_fname == '':
> config_fname = '%s/.config/patman' % os.getenv('HOME')
> - if config_fname:
> - settings.read(config_fname)
> +
> + if not os.path.exists(config_fname):
> + print "No config file found under ~/.config/\nCreating one...\n"
> + CreatePatmanConfigFile(config_fname)
> +
> + settings.read(config_fname)
>
> for name, value in settings.items('alias'):
> alias[name] = value.split(',')
> --
> 1.7.4.1
>
> Regards,
Simon
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH v2 4/4] patman: Handle creation of patman config
2012-04-30 17:37 ` Simon Glass
@ 2012-05-01 3:14 ` Vikram Narayanan
0 siblings, 0 replies; 6+ messages in thread
From: Vikram Narayanan @ 2012-05-01 3:14 UTC (permalink / raw)
To: u-boot
On 4/30/2012 11:07 PM, Simon Glass wrote:
> Hi Vikram,
>
> On Fri, Apr 27, 2012 at 9:39 AM, Vikram Narayanan <vikram186@gmail.com
> <mailto:vikram186@gmail.com>> wrote:
>
>
> patman shouts when it couldn't find a $(HOME)/.config/patman file.
> Handle it in a sane way by creating a new one for the user.
> It looks for a user.name <http://user.name> and user.email in the
> global .gitconfig
> file, waits for the user input if it can't find those.
>
> Signed-off-by: Vikram Narayanan <vikram186@gmail.com
> <mailto:vikram186@gmail.com>>
> Cc: Simon Glass <sjg at chromium.org <mailto:sjg@chromium.org>>
>
>
> Acked-by: Simon Glass <sjg at chromium.org <mailto:sjg@chromium.org>>
>
> In terms of changing the config file to ~/.patman, this could actually
> be a subsequent patch if you like. But there are a few nits below if you
> re-issue.
>
I feel that can be dealt in a separate patch which follows this. For the
few nits, I'll send a v3 _only_ for this patch and not for the whole
series as the other two are ACK'ed and one is decided not to be ACK'ed.
Thanks,
Vikram
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-05-01 3:14 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-27 16:39 [U-Boot] [PATCH v2 4/4] patman: Handle creation of patman config Vikram Narayanan
2012-04-30 8:44 ` Wolfgang Denk
2012-04-30 13:37 ` Vikram Narayanan
2012-04-30 17:10 ` Simon Glass
2012-04-30 17:37 ` Simon Glass
2012-05-01 3:14 ` Vikram Narayanan
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.