コード例 #1
0
ファイル: submodule.py プロジェクト: pombredanne/pgit
	def _exec_add(self, options, args):
		"""Add a new submodule. The last arg may be the url, which is optional"""
		if len(args) < 2 or len(args) > 3:
			raise self.parser.error("arguments may be: name path [url]")
		# END handle arg count
		
		sm = Submodule.add(self.repo, *args, branch=options.branch, no_checkout=options.no_checkout)
		print "Created submodule %r at path %s" % (sm.name, sm.path)
コード例 #2
0
    def _exec_add(self, options, args):
        """Add a new submodule. The last arg may be the url, which is optional"""
        if len(args) < 2 or len(args) > 3:
            raise self.parser.error("arguments may be: name path [url]")
        # END handle arg count

        sm = Submodule.add(self.repo,
                           *args,
                           branch=options.branch,
                           no_checkout=options.no_checkout)
        print "Created submodule %r at path %s" % (sm.name, sm.path)
コード例 #3
0
ファイル: test_diff.py プロジェクト: indra8981/test
    def test_diff_submodule(self):
        """Test that diff is able to correctly diff commits that cover submodule changes"""
        # Init a temp git repo that will be referenced as a submodule
        sub = Repo.init(self.submodule_dir)
        with open(self.submodule_dir + "/subfile", "w") as sub_subfile:
            sub_subfile.write("")
        sub.index.add(["subfile"])
        sub.index.commit("first commit")

        # Init a temp git repo that will incorporate the submodule
        repo = Repo.init(self.repo_dir)
        with open(self.repo_dir + "/test", "w") as foo_test:
            foo_test.write("")
        repo.index.add(['test'])
        Submodule.add(repo,
                      "subtest",
                      "sub",
                      url="file://" + self.submodule_dir)
        repo.index.commit("first commit")
        repo.create_tag('1')

        # Add a commit to the submodule
        submodule = repo.submodule('subtest')
        with open(self.repo_dir + "/sub/subfile", "w") as foo_sub_subfile:
            foo_sub_subfile.write("blub")
        submodule.module().index.add(["subfile"])
        submodule.module().index.commit("changed subfile")
        submodule.binsha = submodule.module().head.commit.binsha

        # Commit submodule updates in parent repo
        repo.index.add([submodule])
        repo.index.commit("submodule changed")
        repo.create_tag('2')

        diff = repo.commit('1').diff(repo.commit('2'))[0]
        # If diff is unable to find the commit hashes (looks in wrong repo) the *_blob.size
        # property will be a string containing exception text, an int indicates success
        self.assertIsInstance(diff.a_blob.size, int)
        self.assertIsInstance(diff.b_blob.size, int)
    repo = Repo(repo_dir)
except InvalidGitRepositoryError as e:
    repo = False

if repo is False:
    # Init repository
    repo = Repo.init(repo_dir)
    repo.git.branch("-m", ODOO_VERSION)

    # Add submodules
    for submodule in REPOS:
        print(f"Adding submodule {submodule['name']}.")
        Submodule.add(
            repo,
            submodule["name"],
            os.path.join(repo_dir, f"submodules/{submodule['name']}"),
            submodule["url"],
            ODOO_VERSION,
            depth=1,
        )
    for submodule in REPOS_MASTER:
        print(f"Adding submodule {submodule['name']}.")
        Submodule.add(
            repo,
            submodule["name"],
            os.path.join(repo_dir, f"submodules/{submodule['name']}"),
            submodule["url"],
            "master",
            depth=1,
        )
    try:
        repo.git.commit("-m", "[ADD] Submodules.")
コード例 #5
0
ファイル: submodule.py プロジェクト: Byron/pgit
 def _exec_add(self, args):
     """Add a new submodule. The last arg may be the url, which is optional"""
     sm = Submodule.add(self.repo, args.name, args.path, args.url, branch=args.branch, no_checkout=args.no_checkout)
     self.log().info("Created submodule %r at path %s", sm.name, sm.path)
コード例 #6
0
ファイル: testGP.py プロジェクト: Danble/flat-test
""" el = repo.heads.master.log()
print(el[0])
print(el[-1]) """
""" print(repo.head.commit.tree.blobs[1].data_stream.read())

print(repo.commit('HEAD'))
commits = list(repo.iter_commits('master'))
print(commits) """
""" for commit in commits:
  print(commit.committed_date)
  print(commit.message) """
#print(repo.active_branch)
""" print(repo.heads)
repo.heads['master'].checkout()
print(repo.head.reference) """
""" print(repo.submodule)
#For creating a submodule
Submodule.add(repo, 'test', './fullstack-interview-test/sm', url='https://github.com/Danble/fullstack-interview-test') """
#print(repo.submodules)

alfonso = repo.branches['alfonsolzrg-add-instructions'].checkout()
generator = repo.iter_commits()
print(next(generator))
print(next(generator))

master = repo.branches['master'].checkout()
generator = repo.iter_commits()
print(next(generator))
print(next(generator))
print(next(generator))
#print(next(generator))