RSB valid status check (was: Contribute to project)

Abhinav Jain jainab.2009 at gmail.com
Mon Feb 19 10:19:14 UTC 2018


Sir,

I have made the changes suggested by you in the code and hopefully, the
issue will be resolved as if the .git file is not found in the directory,
the process will not go ahead and hence the wrong git repository will not
be changed.
I request to please guide me whether anything more is to be done in the
code or should I proceed with a pull request.

Thanks and Regards
Abhinav Jain

On Mon, Feb 19, 2018 at 3:10 AM, Chris Johns <chrisj at rtems.org> wrote:

> Hi Abhinav
>
> I have broken the mail thread as we have switched from contributing to the
> project to a specific fix.
>
> > I have gone through the code concerning the issue raised. I also read
> about the
> > working of git status command and the problem that I am able to figure
> out is
> > that although the existing code is able to check whether the current
> path exists
> > or not but since it is relying on git status to check whether the .git
> file is
> > available or not, a problem is there. The git status checks the current
> > directory for the .git file but in case the current directory doesn't
> have the
> > .git file, it will look for it in the parent directory and if found
> there it
> > will return True, which voids the purpose.
> > So, I think, if a second check is given to validate whether the current
> > directory contains .git file or not will solve the issue.
> > So the code may be:
> > def valid(self):
> >         if path.exists(self.path):
> > if path.exists(path.join(self.path, ".git")):
> >            ec, output = self._run(['status'])
> >            return ec == 0
> >         return False
> > I request you to please guide me whether I proceeded in a right way or
> not.
>
> I am a little confused by the situation that leads to this happening. If
> the RSB
> is being run from a git repo and the build references a git repo the RSB
> will
> clone and update the repo so a 'valid' check to repo within the RSB's clone
> should not fail. This is happening because it has been working for a long
> time.
> I can see this happening if someone plays the source/git tree of files or
> maybe
> a clone failed for some reason and a directory is left. Maybe git does
> that.
>
> To make things more robust a check for the .git directory makes sense.
> There is
> no need to check the path twice, a single check is all that is needed. I
> suggest
> a new function be added to the class call '_valid_repo_path' which is:
>
>     def _valid_repo_path(self):
>         return path.exists(path.join(self.path, '.git')
>
> and all 'path.exists(self.path)' in the class be replaced by this call.
>
> Thanks
> Chris
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20180219/7d599176/attachment-0002.html>


More information about the devel mailing list