RSB valid status check (was: Contribute to project)

Chris Johns chrisj at rtems.org
Sun Feb 18 21:40:23 UTC 2018


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


More information about the devel mailing list