Re: RSB valid status check (was: Contribute to project)
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 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 > ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: RSB valid status check (was: Contribute to project)
On 19/02/2018 21:19, Abhinav Jain wrote: > 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. Excellent. Please post for review. > I request to please guide me whether anything more is to be done in the code > or > should I proceed with a pull request. I assume you mean a github pull request. RTEMS uses patches sent to this list for review. The top page of the Wiki has a section called RTEMS Developer Information and in that section are links to User Git access and submitting patches. You can also attach the patch to the ticket. Chris ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH] sb: Optional location of the patches directory
On 17/02/2018 03:29, Maksim E. Kozlov wrote: > This patch adds an option for changing location of the patches directory > as for source, build and tmp. This can be useful when you use CI/Docker > services, for example, or maybe in other cases when you do not want to > download patches for every build but can not preserve cloned repo. > > Maksim E. Kozlov (1): > sb: Add option to set location of the patches directory > > source-builder/sb/options.py | 2 ++ > 1 file changed, 2 insertions(+) > I have pushed this. Would it be possible to get a patch for the documentation? https://git.rtems.org/rtems-docs/tree/rsb Thanks Chris ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: RSB valid status check (was: Contribute to project)
Sir, I have attached the patch file with this mail. I have tried to follow all the conventions that were listed in the User Git page. I request you to please check and guide me whether I have done it correctly or not or whether something more is to be done. Thanks and Regards Abhinav Jain On Tue, Feb 20, 2018 at 4:13 AM, Chris Johns wrote: > On 19/02/2018 21:19, Abhinav Jain wrote: > > 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. > > Excellent. Please post for review. > > > I request to please guide me whether anything more is to be done in the > code or > > should I proceed with a pull request. > > I assume you mean a github pull request. RTEMS uses patches sent to this > list > for review. The top page of the Wiki has a section called RTEMS Developer > Information and in that section are links to User Git access and submitting > patches. You can also attach the patch to the ticket. > > Chris > From 273baf1527f50ae6dd4832ddf9434a9f4630375a Mon Sep 17 00:00:00 2001 From: Abhinav Jain Date: Mon, 19 Feb 2018 15:35:59 +0530 Subject: [PATCH] Function added to check the validity of git repository. Earlier the function valid was checking the validity of the git repository, the program was working in. For doing this the function was first checking whether path exists or not and after that it was checking whether the directory is a git repository or not and to do so, it was relying on git status. The git status looks for the .git file in the current directory and if not found it will look up in the tree and if finds a .git file there it will return valid, which voids the purpose of use. Now to solve this problem, a function _valid_repo_path is created to check for the .git file and every function which looks for the validity of git repository will call this function to check. --- source-builder/sb/git.py | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/source-builder/sb/git.py b/source-builder/sb/git.py index be23396..82b23fb 100644 --- a/source-builder/sb/git.py +++ b/source-builder/sb/git.py @@ -38,9 +38,13 @@ class repo: if ec: raise error.general('git command failed (%s): %d' % (self.git, ec)) + +def _valid_repo_path(self): + return path.exists(path.join(self.path, '.git')) + def _run(self, args, check = False): e = execute.capture_execution() -if path.exists(self.path): +if _valid_repo_path(): cwd = self.path else: cwd = None @@ -52,6 +56,7 @@ class repo: self._git_exit_code(exit_code) return exit_code, output + def __init__(self, _path, opts = None, macros = None): self.path = _path self.opts = opts @@ -122,7 +127,7 @@ class repo: def status(self, submodules_always_clean = False): _status = {} -if path.exists(self.path): +if _valid_repo_path(): if submodules_always_clean: submodules = self.submodules() else: @@ -166,7 +171,7 @@ class repo: return not (len(_status) == 1 and 'branch' in _status) def valid(self): -if path.exists(self.path): +if _valid_repo_path(): ec, output = self._run(['status']) return ec == 0 return False -- 1.9.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel