All of lore.kernel.org
 help / color / mirror / Atom feed
* b4 ty not picking up per-remote git config properties
@ 2020-05-07 11:42 Will Deacon
  2020-05-07 17:37 ` Konstantin Ryabitsev
  0 siblings, 1 reply; 3+ messages in thread
From: Will Deacon @ 2020-05-07 11:42 UTC (permalink / raw)
  To: konstantin; +Cc: tools

Hi Konstantin,

I've been having trouble persuading 'b4 ty' to honour the 'b4-treename'
and 'b4-commit-url-mask' properties if they are specified on a per-remote
basis. This seems to be because get_branch_info() has expectations about
branch naming to which I'm probably not adhering.

In my specific case, I have a branch called 'for-joerg/arm-smmu/updates'
which has a remote called 'wd-korg', so my .git/config contains:

[remote "wd-korg"]
	...
	b4-treename = will
	b4-commit-url-mask = https://git.kernel.org/will/c/%.12s

[branch "for-joerg/arm-smmu/updates"]
	remote = wd-korg
	merge = refs/heads/for-joerg/arm-smmu/updates

but 'b4 ty' always takes the properties from my top-level .gitconfig.

I've hacked ty.py as below to get things working but, believe it or not,
this is the first time I've written any python so I suspect it's all a
load of rubbish.

Will

--->8

diff --git a/b4/ty.py b/b4/ty.py
index 33baddbeaaa8..04ef63899563 100644
--- a/b4/ty.py
+++ b/b4/ty.py
@@ -560,29 +560,14 @@ def get_branch_info(gitdir, branch):
 
     BRANCH_INFO = dict()
 
-    if branch.find('/') < 0:
-        # Not a remote branch
-        return BRANCH_INFO
-
-    # Get a list of all remotes
-    gitargs = ['remote', 'show']
-    lines = b4.git_get_command_lines(gitdir, gitargs)
-    if not len(lines):
-        # No remotes? Hmm...
-        return BRANCH_INFO
-
-    remote = None
-    for entry in lines:
-        if branch.find('%s/' % entry) == 0:
-            remote = entry
-            break
-
-    if remote is None:
+    remotecfg = b4.get_config_from_git('branch\\.' + branch + '\\.remote')
+    if remotecfg is None or 'remote' not in remotecfg:
         # Not found any matching remotes
         return BRANCH_INFO
 
+    remote = remotecfg['remote']
     BRANCH_INFO['remote'] = remote
-    BRANCH_INFO['branch'] = branch.replace('%s/' % remote, '')
+    BRANCH_INFO['branch'] = branch
 
     # Grab template overrides
     remotecfg = b4.get_config_from_git('remote\\.%s\\..*' % remote)

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: b4 ty not picking up per-remote git config properties
  2020-05-07 11:42 b4 ty not picking up per-remote git config properties Will Deacon
@ 2020-05-07 17:37 ` Konstantin Ryabitsev
  2020-05-11 15:03   ` Will Deacon
  0 siblings, 1 reply; 3+ messages in thread
From: Konstantin Ryabitsev @ 2020-05-07 17:37 UTC (permalink / raw)
  To: Will Deacon; +Cc: tools

On Thu, May 07, 2020 at 12:42:56PM +0100, Will Deacon wrote:
> Hi Konstantin,
> 
> I've been having trouble persuading 'b4 ty' to honour the 'b4-treename'
> and 'b4-commit-url-mask' properties if they are specified on a per-remote
> basis. This seems to be because get_branch_info() has expectations about
> branch naming to which I'm probably not adhering.
> 
> In my specific case, I have a branch called 'for-joerg/arm-smmu/updates'
> which has a remote called 'wd-korg', so my .git/config contains:
> 
> [remote "wd-korg"]
> 	...
> 	b4-treename = will
> 	b4-commit-url-mask = https://git.kernel.org/will/c/%.12s
> 
> [branch "for-joerg/arm-smmu/updates"]
> 	remote = wd-korg
> 	merge = refs/heads/for-joerg/arm-smmu/updates
> 
> but 'b4 ty' always takes the properties from my top-level .gitconfig.
> 
> I've hacked ty.py as below to get things working but, believe it or not,
> this is the first time I've written any python so I suspect it's all a
> load of rubbish.

It's not, I used it largely without changes. The latest master and 
stable-0.4.y should be a lot less naive about local and remote branch 
names.

Best,
-K

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: b4 ty not picking up per-remote git config properties
  2020-05-07 17:37 ` Konstantin Ryabitsev
@ 2020-05-11 15:03   ` Will Deacon
  0 siblings, 0 replies; 3+ messages in thread
From: Will Deacon @ 2020-05-11 15:03 UTC (permalink / raw)
  To: Konstantin Ryabitsev; +Cc: tools

On Thu, May 07, 2020 at 01:37:50PM -0400, Konstantin Ryabitsev wrote:
> On Thu, May 07, 2020 at 12:42:56PM +0100, Will Deacon wrote:
> > Hi Konstantin,
> > 
> > I've been having trouble persuading 'b4 ty' to honour the 'b4-treename'
> > and 'b4-commit-url-mask' properties if they are specified on a per-remote
> > basis. This seems to be because get_branch_info() has expectations about
> > branch naming to which I'm probably not adhering.
> > 
> > In my specific case, I have a branch called 'for-joerg/arm-smmu/updates'
> > which has a remote called 'wd-korg', so my .git/config contains:
> > 
> > [remote "wd-korg"]
> > 	...
> > 	b4-treename = will
> > 	b4-commit-url-mask = https://git.kernel.org/will/c/%.12s
> > 
> > [branch "for-joerg/arm-smmu/updates"]
> > 	remote = wd-korg
> > 	merge = refs/heads/for-joerg/arm-smmu/updates
> > 
> > but 'b4 ty' always takes the properties from my top-level .gitconfig.
> > 
> > I've hacked ty.py as below to get things working but, believe it or not,
> > this is the first time I've written any python so I suspect it's all a
> > load of rubbish.
> 
> It's not, I used it largely without changes. The latest master and 
> stable-0.4.y should be a lot less naive about local and remote branch 
> names.

Cheers, Konstantin!

Will

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-05-11 15:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-07 11:42 b4 ty not picking up per-remote git config properties Will Deacon
2020-05-07 17:37 ` Konstantin Ryabitsev
2020-05-11 15:03   ` Will Deacon

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.