diff mbox series

[RFC,5/7] lib/oe/buildcfg.py: Add additional git functions

Message ID 20231107152641.1043-7-jermain.horsman@nedap.com
State New
Headers show
Series bitbake-layers: Add update-layers-setup | expand

Commit Message

jhatnedap@gmail.com Nov. 7, 2023, 3:26 p.m. UTC
From: Jermain Horsman <jermain.horsman@nedap.com>

Includes a function to determine the default remote.

Signed-off-by: Jermain Horsman <jermain.horsman@nedap.com>
---
 meta/lib/oe/buildcfg.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Martin Jansa Feb. 18, 2024, 3:11 p.m. UTC | #1
Was there a reason why this wasn't merged in the end (other than being sent
as RFC)?

We're using git describe in webOS for long time (through our bbclass:
https://github.com/webosose/meta-webosose/blob/master/meta-webos/classes/webos_base.bbclass#L114
)

I would be happy to drop it from our bbclass to use this shared function.

Regards,

On Tue, Nov 7, 2023 at 4:27 PM Jermain Horsman <jermain.horsman@nedap.com>
wrote:

> From: Jermain Horsman <jermain.horsman@nedap.com>
>
> Includes a function to determine the default remote.
>
> Signed-off-by: Jermain Horsman <jermain.horsman@nedap.com>
> ---
>  meta/lib/oe/buildcfg.py | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
>
> diff --git a/meta/lib/oe/buildcfg.py b/meta/lib/oe/buildcfg.py
> index f9cb0cc74c..2ca654e56e 100644
> --- a/meta/lib/oe/buildcfg.py
> +++ b/meta/lib/oe/buildcfg.py
> @@ -50,6 +50,22 @@ def get_metadata_git_remote_url(path, remote):
>          uri = ''
>      return uri.strip()
>
> +def get_metadata_git_default_remote(path):
> +    remotes = get_metadata_git_remotes(path)
> +    if len(remotes) == 1:
> +        default_remote = remotes[0]
> +    else:
> +        try:
> +            default_remote, _ = bb.process.run('git config --local
> checkout.defaultRemote', cwd=path)
> +        except bb.process.ExecutionError:
> +            default_remote = ""
> +        if not default_remote:
> +            try:
> +                default_remote, _ = bb.process.run('git config
> checkout.defaultRemote', cwd=path)
> +            except bb.process.ExecutionError:
> +                default_remote = ""
> +    return default_remote.strip()
> +
>  def get_metadata_git_describe(path):
>      try:
>          describe, _ = bb.process.run('git describe --tags', cwd=path)
> --
> 2.42.0.windows.2
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#190295):
> https://lists.openembedded.org/g/openembedded-core/message/190295
> Mute This Topic: https://lists.openembedded.org/mt/102444609/3617156
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
> martin.jansa@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
Jermain Horsman Feb. 19, 2024, 9:01 a.m. UTC | #2
> Was there a reason why this wasn't merged in the end (other than being sent as RFC)?

I'm assuming you meant to reply to this one instead:
https://lists.openembedded.org/g/openembedded-core/message/190292

I did not include this in the final version as we ended up going in a bit of a different direction,
as a result I did not change the file that used these functions, and therefore did not include this patch.

I'd be more than happy to send this as a standalone though.

Sincerely,

Jermain Horsman
diff mbox series

Patch

diff --git a/meta/lib/oe/buildcfg.py b/meta/lib/oe/buildcfg.py
index f9cb0cc74c..2ca654e56e 100644
--- a/meta/lib/oe/buildcfg.py
+++ b/meta/lib/oe/buildcfg.py
@@ -50,6 +50,22 @@  def get_metadata_git_remote_url(path, remote):
         uri = ''
     return uri.strip()
 
+def get_metadata_git_default_remote(path):
+    remotes = get_metadata_git_remotes(path)
+    if len(remotes) == 1:
+        default_remote = remotes[0]
+    else:
+        try:
+            default_remote, _ = bb.process.run('git config --local checkout.defaultRemote', cwd=path)
+        except bb.process.ExecutionError:
+            default_remote = ""
+        if not default_remote:
+            try:
+                default_remote, _ = bb.process.run('git config checkout.defaultRemote', cwd=path)
+            except bb.process.ExecutionError:
+                default_remote = ""
+    return default_remote.strip()
+
 def get_metadata_git_describe(path):
     try:
         describe, _ = bb.process.run('git describe --tags', cwd=path)