Sir,

I have tried to incorporate the changes suggested by you.
I request you to please check the new patch file and guide me if some more
improvement is needed to be done.

Thanks and Regards
Abhinav Jain



On Tue, Feb 20, 2018 at 8:27 PM, Abhinav Jain <jainab.2...@gmail.com> wrote:

> Sir,
>
> I will edit the current patch accordingly and will take care of this in
> the future.
>
> Thanks and Regards
> Abhinav Jain
>
> On Tue, Feb 20, 2018 at 7:31 PM, Gedare Bloom <ged...@rtems.org> wrote:
>
>> Oops, I should read my mail better. Thanks for breaking this out Chris.
>> Abhinav,
>>
>> On Tue, Feb 20, 2018 at 1:12 AM, Abhinav Jain <jainab.2...@gmail.com>
>> wrote:
>> > 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.
>> >
>> I won't comment on the code, I'll let Chris do that. However, this
>> patch has a few issues that should be addressed.
>> 1. Use line breaks in your commit message. About 70-80 characters per
>> line max, please.
>> 2. The "short message" can omit "function added to", basically all
>> patches add some code, so this is a bit redundant. You can just say
>> "Check the validity ..."
>> 3. The commit message should use "Closes #nnnn." somewhere, usually in
>> the end of the commit, if it is fixing/closing a ticket.
>> 4. The commit message may be less verbose, if the extra details about
>> the change are already in the ticket.
>> 5. Avoid adding extra white spaces randomly, e.g. hunk #2 of the
>> patch, and avoid introducing white space new lines where one exists,
>> creating 2 blank lines in a row.
>> 6. You may like to try to get git-send-email to work for you. It is a
>> little nicer for submitting patches to mailing list.
>> https://devel.rtems.org/wiki/Developer/Git/Users#Configuring
>> git-send-emailtouseGMail
>>
>> -Gedare
>>
>> > Thanks and Regards
>> > Abhinav Jain
>> >
>> > On Tue, Feb 20, 2018 at 4:13 AM, Chris Johns <chr...@rtems.org> 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 d2e4586b2b6886004287bd24e7cf7faf48926799 Mon Sep 17 00:00:00 2001
From: Abhinav Jain <jainab.2...@gmail.com>
Date: Tue, 20 Feb 2018 21:54:44 +0530
Subject: [PATCH] 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. Since 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. Closes #2522
---
 source-builder/sb/git.py | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/source-builder/sb/git.py b/source-builder/sb/git.py
index be23396..0d139f9 100644
--- a/source-builder/sb/git.py
+++ b/source-builder/sb/git.py
@@ -38,9 +38,12 @@ 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
@@ -122,7 +125,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 +169,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
@@ -233,4 +236,4 @@ if __name__ == '__main__':
     print('g.dirty():', g.dirty())
     print('g.remotes():', g.remotes())
     print('g.email():', g.email())
     print('g.head():', g.head())
\ No newline at end of file
-- 
1.9.1

_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Reply via email to