0

file path = repo_name/abc/xyz.yml

repo (is the git repo object)

I want to be able to check if the repo consists of the file by returning a Boolean.

something like:

def fileInRepo(repo, filePath):
   if filePath in repo.files:
      return true
   else:
      return false
  • a repository on the desktop or on the web ? – D.L Mar 17 '22 at 18:46
  • Repositories consist of commits, not files. Commits contain files, but each commit may have a completely different set of files. So what does it mean to ask if a file is "in a repository"? Does it matter which commit(s), if any, contain a file of that name? – torek Mar 18 '22 at 01:30

1 Answers1

0

I had a problem like yours and I resolved it using this script.

    import re
    import requests
    from bs4 import BeautifulSoup

    def check_script(self, git_repo_link: str, name: str) -> bool:
        try:
            r = requests.get(git_repo_link)
            html_doc = r.text
            soup = BeautifulSoup(html_doc)
            file = soup.find_all(title=re.compile(name))
            if file:
                return True
            else:
                return False
        except Exception:
            return False

Hope this is helpful for you. Thank you.

Venus713
  • 1,441
  • 12
  • 24