All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robert Yang <liezhi.yang@windriver.com>
To: Mark Hatle <mark.hatle@windriver.com>,
	<bitbake-devel@lists.openembedded.org>
Subject: Re: [PATCH 4/5] fetch2/gitsm: Add clean function
Date: Fri, 15 Mar 2019 11:48:52 +0800	[thread overview]
Message-ID: <45ee10bc-6af4-22f8-b503-d2528572b459@windriver.com> (raw)
In-Reply-To: <f1dbdece-5627-16a1-4104-3cd37c5369d8@windriver.com>

Hi Mark,

On 3/14/19 10:41 PM, Mark Hatle wrote:
> On 3/14/19 4:28 AM, Robert Yang wrote:
>> The git's clean can only remove parent git repo from DL_DIR, but doesn't remove
>> submodules, this patch fixes the problem.
>>
>> Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
>> ---
>>   bitbake/lib/bb/fetch2/gitsm.py | 15 +++++++++++++--
>>   1 file changed, 13 insertions(+), 2 deletions(-)
>>
>> diff --git a/bitbake/lib/bb/fetch2/gitsm.py b/bitbake/lib/bb/fetch2/gitsm.py
>> index b21fed2..bb61093 100644
>> --- a/bitbake/lib/bb/fetch2/gitsm.py
>> +++ b/bitbake/lib/bb/fetch2/gitsm.py
>> @@ -76,8 +76,8 @@ class GitSM(Git):
>>           for name in ud.names:
>>               try:
>>                   gitmodules = runfetchcmd("%s show %s:.gitmodules" % (ud.basecmd, ud.revisions[name]), d, quiet=True, workdir=workdir)
>> -            except:
>> -                # No submodules to update
>> +            except Exception as esc:
>> +                logger.info("No submodules found: %s" % workdir)
> 
> We don't want the log message.  git submodules are processed recursively, and
> the end of the recursion will -always- have 'gitsm' items that have no
> submodules.  This is also why it was a generic except, because we really don't
> care WHAT the exception is, only that if one happens -- we know the command
> failed and to simply ignore it and finish the iteration.

Sorry, I forgot to reply on this just now. Submodule is a little different and
complicated then other SCMs, for exmaple, when I worked on gitsm' clean()
function, it always didn't work which puzzled me a lot, at last I found that
I had called Git.clean() before self.process_submodules:

Git.clean(self, ud, d)
self.process_submodules(ud, ud.clonedir, clean_submodule, d)

So that the parent repo had gone before submodules, but there was no message
told me this, it just failed quietly, so I had to debug it line by line.

The logger.info() goes into log.do_fetch which won't affect users by default,
but it would help to understand what happend when they need debug.

// Robert

> 
>                    continue
>>   
>>               for m, md in parse_gitmodules(gitmodules).items():
>> @@ -164,6 +164,17 @@ class GitSM(Git):
>>           Git.download(self, ud, d)
>>           self.process_submodules(ud, ud.clonedir, download_submodule, d)
>>   
>> +    def clean(self, ud, d):
>> +        def clean_submodule(ud, url, module, modpath, d):
>> +            try:
>> +                newfetch = Fetch([url], d, cache=False)
>> +                newfetch.clean()
>> +            except Exception as e:
>> +                logger.warn('gitsm: submodule clean failed: %s %s' % (type(e).__name__, str(e)))
>> +
>> +        self.process_submodules(ud, ud.clonedir, clean_submodule, d)
>> +        Git.clean(self, ud, d)
>> +
> 
> I don't see 'clean_submodule' implemented in this patch.  The process_submodules
> will simply call that function, if it's not defined it will error or not do
> anything if it finds a submodule.
> 
>>       def unpack(self, ud, destdir, d):
>>           def unpack_submodules(ud, url, module, modpath, d):
>>               url += ";bareclone=1;nobranch=1"
>>
> 
> 


  parent reply	other threads:[~2019-03-15  3:43 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-14  9:28 [PATCH 0/5] fetch2: Fixes for git and gitsm Robert Yang
2019-03-14  9:28 ` [PATCH 1/5] fetch2/git: Fix clean to remove clonedir Robert Yang
2019-03-14  9:28 ` [PATCH 2/5] fetch2: Add get_mirrorname() Robert Yang
2019-03-21 23:42   ` Richard Purdie
2019-03-22  3:51     ` Robert Yang
2019-03-14  9:28 ` [PATCH 3/5] fetch2: Print SCMs list when SRCREV_FORMAT is not set Robert Yang
2019-03-14  9:28 ` [PATCH 4/5] fetch2/gitsm: Add clean function Robert Yang
2019-03-14 12:34   ` Lisicki, Raphael
2019-03-15  2:50     ` Robert Yang
2019-03-15 15:44       ` Mark Hatle
2019-03-19  6:41         ` Robert Yang
2019-03-14 14:41   ` Mark Hatle
2019-03-15  2:52     ` Robert Yang
2019-03-15 15:46       ` Mark Hatle
2019-03-15  3:48     ` Robert Yang [this message]
2019-03-14  9:28 ` [PATCH 5/5] fetch2: Add gitsm's function process_submodules() Robert Yang
2019-03-14 14:46   ` Mark Hatle
2019-03-15  3:37     ` Robert Yang
2019-03-15 15:55       ` Mark Hatle
2019-03-19  3:47         ` Robert Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=45ee10bc-6af4-22f8-b503-d2528572b459@windriver.com \
    --to=liezhi.yang@windriver.com \
    --cc=bitbake-devel@lists.openembedded.org \
    --cc=mark.hatle@windriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.