summaryrefslogtreecommitdiffstats
path: root/project.py
Commit message (Collapse)AuthorAgeFilesLines
* implement optional 'pushurl' in the manifest fileSteve Rae2016-09-201-0/+4
| | | | | | | | Allow the 'remote' element in the manifest file to define an optional 'pushurl' attribute which is passed into the .git/config file. Change-Id: If342d299d371374aedc4440645798888869c9714 Signed-off-by: Steve Rae <steve.rae@raedomain.com>
* Merge "Fix submodule checkout error when using sync-s option"David Pursehouse2016-09-141-1/+1
|\
| * Fix submodule checkout error when using sync-s optionAymen Bouaziz2016-06-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | When sync-s="true" option is used, the checkout of a submodule will try to use the revision attribute of the parent project. If this revision is a named reference, the checkout will fail if there is no reference with this name in the submodule. The proposed solution is to use the git commit id as revisionExpr for submodules. Change-Id: Ie8390a11957fd6a9c61289c6861d13cb3fa11678
* | RepoHook: do not list options twice during hash based approvalJonathan Nieder2016-08-181-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Instead of Do you want to allow this script to run (yes/yes-never-ask-again/NO)? (yes/always/NO)? ask Do you want to allow this script to run (yes/always/NO)? Change-Id: I5f5a2d0e88086a8d85e54fb8623a62d74a20956a Signed-off-by: Jonathan Nieder <jrn@google.com>
* | Merge "project: Set config option to skip lfs smudge filter"David Pursehouse2016-08-171-0/+1
|\ \
| * | project: Set config option to skip lfs smudge filterDavid Pursehouse2016-08-161-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | During sync, repo runs `git read-tree --reset -u -v HEAD` which causes git-lfs's smudge filter to run. However this fails because git-lfs does not work with bare repositories. Add lfs.filter configuration to the project config as suggested in the comments on the upstream git-lfs client issue [1]. This prevents the smudge filter from running, and the sync completes successfully. For any projects that have LFS objects, `git lfs pull` must be executed. [1] https://github.com/github/git-lfs/issues/1422 Bug: Issue 224 Change-Id: I091ff37998131e2e6bbc59aa37ee352fe12d7fcd
* | | RepoHook: allow users to approve hooks via manifestsMike Frysinger2016-08-161-22/+81
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The constant prompting when registered hooks change can be tedious and has a large multiplication factor when the project is large (e.g. the AOSP). It gets worse as people want to write more checks, hooks, docs, and tests (or fix bugs), but every CL that goes in will trigger a new prompt to approve. Let's tweak our trust model when it comes to hooks. Since people start off by calling `repo init` with a URL to a manifest, and that manifest defines all the hooks, anchor trust in that. This requires that we get the manifest over a trusted link (e.g. https or ssh) so that it can't be MITM-ed. If the user chooses to use an untrusted link (e.g. git or http), then we'll fallback to the existing hash based approval. Bug: Issue 226 Change-Id: I77be9e4397383f264fcdaefb582e345ea4069a13
* | Merge "repo: Repo does not always handle '.' parameter correctly"David Pursehouse2016-08-141-1/+1
|\ \
| * | repo: Repo does not always handle '.' parameter correctlyMark E. Hamilton2016-04-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The repo script allows a manifest to specify a '.' as the path the top-level directory, which co-locates the .git and .repo directories, and places files from the git repository at the top-level: <project name="proj_name" path="." /> <project name="sierra.other.git" path="other" /> Most commands work correctly with this setup. Some commands, however, fail to find the project. For instance, 'repo sync' works, and 'repo sync .' works in a sub-project ('other' in this case) but 'repo sync .' in the top-level directory fails with the error: error: project . not found There are two reasons for this: 1. The self.worktree attribute of the Project object is not normalized, so with a '.' for path its value would be '/my/project/root/.'. This is fine when used as a path, since it's the same path as '/my/project/root', but when used in a string comparison it fails. This commit applies os.path.normpath() to that value before storing it. 2. The _GetProjectByPath method in command.py was not checking the path against manifest.topdir, so even once it was normalized the project was not found. This commit adds a check against manifest.topdir if the loop drops out without finding a project. Change-Id: Ic84d053f1bbb5a357cad566805d5a326ae8246d2
* | | Merge "Fix variable assignment"David Pursehouse2016-06-291-1/+4
|\ \ \
| * | | Fix variable assignmentAymen Bouaziz2016-06-281-1/+4
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | If upstream string is empty, current_branch_only variable will be assigned to an empty string. This is not what we expect here as this variable is a boolean. Change-Id: Ibba935e25a74c2be1e50c88b4b403cf394ba365e
* | | Merge "Fix XmlManifest.Save with remotes that have 'alias' set"Dan Willemsen2016-04-221-1/+3
|\ \ \
| * | | Fix XmlManifest.Save with remotes that have 'alias' setDan Willemsen2016-04-221-1/+3
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the alias attribute is set for a remote, the RemoteSpec attached to a Project only contains the alias name used by git, not the original name used in the manifest. But that's not enough information to reconstruct the manifest, so save off the original manifest name as another RemoteSpec parameter, only used to write the manifest out. Bug: Issue 181 Bug: Issue 219 Change-Id: Id7417dfd6ce5572e4e5fe14f22924fdf088ca4f3
* / | diffmanifests: support custom git pretty format stringsSebastian Schuberth2016-04-211-4/+9
|/ / | | | | | | Change-Id: I29f4f1351c421f393328514d145df1a96aed9ee2
* | Fix symlinking of new projectsDan Willemsen2016-04-051-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We weren't copying these lists, so the += was actually changing the underlying lists. When a new project was added to the manifest, we run _CheckDirReference against the manifest project with share_refs=True, which added the working_tree_* to the shareable_* lists. Then, when we load the new manifest and create the new project, it uses the lists that already contain the working_tree_* files, even though we passed share_refs=False. This happens reliably under the above conditions, but doesn't seem to happen when syncing a fresh tree. So we've got a mixture of links that may need to be cleaned up later. This patch will just stop it from happening in the future. Change-Id: Ib7935bfad78af1e494a75e55134ec829f13c2a41
* | Merge changes from topic 'pylint-pep8-cleanup'David Pursehouse2016-03-151-110/+149
|\ \ | | | | | | | | | | | | | | | * changes: command.py: Cleaned up pylint/pep8 violations project.py: Cleaned up pylint/pep8 violations
| * | project.py: Cleaned up pylint/pep8 violationsMark E. Hamilton2016-03-021-110/+149
| |/ | | | | | | | | | | | | | | | | | | | | | | I noticed when running pylint (as the SUBMITTING_PATCHES file directs) that there were a number of violations reported. This makes it difficult to see violations I might have introduced. This commit corrects all pylint violations in the project.py script. This script now has a pylint score of 10.0, and no violations reported by pep8. Change-Id: I1462fd84f5b6b4c0dc893052671373e7ffd838f1
* / RepoHook: set __file__ when running the hookMike Frysinger2016-03-051-1/+1
|/ | | | | | | | | | | | | | | | | | | A common design pattern is to use __file__ to find the location of the active python module to assist in output or loading of related assets. The current hook systems runs the pre-upload.py hook in a context w/out that set leading to runtime errors: $ repo upload --cbr . ERROR: Traceback (most recent call last): File ".../repo/project.py", line 481, in _ExecuteHook self._script_fullpath, 'exec'), context) File ".../repohooks/pre-upload.py", line 32, in <module> path = os.path.dirname(os.path.realpath(__file__)) NameError: name '__file__' is not defined Define this variable in this context so code can safely use it. Change-Id: If6331312445fa61d9351b59f83abcc1c99ae6748
* Fix prune when bare git has detached headDan Willemsen2015-12-151-3/+4
| | | | | | | | | | | | | | | | We don't really use HEAD much in the bare git repositories, but there have been reports of errors in git-symbolic-ref: symbolic-ref: fatal: Refusing to point HEAD outside of refs/ That happen when the bare git repo is in the detached head state. It's possible that previous operations were killed while we were pruning branches. Use DetachHead instead of SetHead if we're restoring the repo into a detached head state. Change-Id: I9062e8957bc70367d3ded399685ac026fbb421fc
* Check for broken links when updating linkfilesDan Willemsen2015-11-181-1/+1
| | | | | | | | If a linkfile is a broken link (destination does not exist), and it needs to be updated, we didn't notice that it needed to be removed first. Use lexists instead of exists to check for this condition. Change-Id: I1f6a1f0193d3fd2b9f7a647836044997f6ab32eb
* Sync: Add option to prune refs during syncDavid Pursehouse2015-10-271-3/+8
| | | | | | | | By passing --prune to the sync command, the --prune option is given to the `git fetch`, causing refs that no longer exist on the remote to be removed. Change-Id: I3cedacce14276d96ac2d5aabf2d07fd05e92bc02
* _CopyAndLinkFiles even if the sources haven't changedDan Willemsen2015-09-031-0/+4
| | | | | | | The source or destination attributes may have changed even if the source didn't, so we need to make sure that these are up to date. Change-Id: I266ef3598ddda7e8c23bc9c6a049905ddc586348
* GITC: Add repo start support.Simran Basi2015-08-281-6/+12
| | | | | | | | | | | | | | | | | | | | | Add repo start support for GITC checkouts. If the user is in the GITC FS view, they can now run repo start to check out the sources and create a new working branch. When "repo start" is called on a GITC project, the revision tag is set to an empty string and saved in a new tag: old-revision. This tells the GITC filesystem to display the local copy of the sources when being viewed. The local copy is created by pulling the project sources and the new branch is created based off the original project revision. Updated main.py to setup each command's gitc_manifest when appropriate. Updated repo sync's logic to sync opened projects and updating the GITC manifest file for the rest. Change-Id: I7e4809d1c4fc43c69b26f2f1bebe45aab0cae628
* project.py: Improve message shown when hook is not replacedDavid Pursehouse2015-08-251-1/+1
| | | | | | | | | | If a hook file has been modified locally, it will not be replaced. Improve the message to make this clearer. Also change it from an error to a warning. Change-Id: I62c635390f24d2868db17717c247861b0381c99f
* project.py: Consistently use the _error method to print error messagesDavid Pursehouse2015-08-251-7/+8
| | | | | | | | Use the _error method instead of directly calling `print`. Also add a new _warn convenience method. Change-Id: Ia332c14ef8d9d1fe2df128dbf36b5521802ccdf1
* Merge "Support smart-sync through persistent-http[s]"Dan Willemsen2015-08-191-37/+2
|\
| * Support smart-sync through persistent-http[s]Dan Willemsen2015-08-191-37/+2
| | | | | | | | | | | | | | Use the same cookies and proxy that git traffic goes through for persistent-http[s] to support authentication for smart-sync. Change-Id: I20f4a281c259053a5a4fdbc48b1bca48e781c692
* | Merge "Fix formatting of message when retrying clone"Dan Willemsen2015-08-191-1/+1
|\ \
| * | Fix formatting of message when retrying cloneDavid Pursehouse2015-08-191-1/+1
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Passing the force_sync variable into the string formatting results in the message: "Retrying clone after deleting None" or "Retrying clone after deleting True". Pass the name of the git directory instead. Also, move the print inside the if-block so it's only displayed when the retry is actually going to be attempted. Change-Id: I76d9ecc176cecee4ad512d13e9d1f6bd36aacbbb
* | Merge "Include project path in --force-sync error message"Dan Willemsen2015-08-191-1/+4
|\ \ | |/ |/|
| * Include project path in --force-sync error messageSimon Ruggier2015-08-041-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For projects that have been cloned outside of the repo command (or cloned a long time ago), commit abaa7f312f1b6c8d11d7c757fe909900ce5788b5 introduced an error message to invite the user to use --force-sync. However, due to the risk of data loss, it's useful to know which project's git directory is being replaced before deciding whether or not to provide --force-sync. This change updates the exception's associated value to include the project's relative path and explain to the user how they can resolve the issue. A previous version of this commit used the project name. However, for projects that have multiple work trees, the name can be ambiguous, while the path clearly identifies which git directory will be replaced. Change-Id: If717e66fda4d19accc0a8e889a91f4cd4ff14dff
* | Fix shallow clone behaviorDan Willemsen2015-08-031-10/+7
|/ | | | | | | | | | | | | | | | The existing code here makes sure that switching clone-depth from on to off actually causes the history to be fully restored. Unfortunately, it does this by fetching the full history every time the fetch spec changes. Switching between two clone-depth="1" branches will fetch far more than the top commit. Instead, when not using clone-depth, pass --depth=2147483647 to git fetch so that it ensures that we have the entire history. That is slightly less efficient, so limit it to only when there are shallow objects in the project by checking for the existance of the 'shallow' file. Change-Id: Iee0cfc9c6992c208344b1d9123769992412db67b
* Fix _ReferenceGitDir symlinkingDan Willemsen2015-07-301-1/+2
| | | | | | | | | | | | | | | | | | | | | | This fixes these errors: ... File ".repo/repo/project.py", line 2371, in _ReferenceGitDir os.symlink(os.path.relpath(src, os.path.dirname(dst)), dst) OSError: [Errno 17] File exists Which was happening for checkouts that were created before v1.12.8, when project-objects was created. Nothing had yet been forcing these checkouts to use project-objects, until the recent verification changes. In this OSError case, we already created the symlink, so src == dst, and the directory did not exist. This caused us to run os.makedirs the os.symlink on the same file. dst really should be the file in gitdir, not the target of that symlink if it exists. So just use realpath for the dotgit portion of the path. Change-Id: Iff5396a2093de91029c42cf38aa57131fd22981c
* Add option to correct gitdir when syncingv1.12.25Kevin Degi2015-07-291-10/+34
| | | | | | | | | | | | | In some cases, a user may wish to continue with a sync even though it would require overwriting an existing git directory. This behavior is not safe as a default because it could result in the loss of some user data, but as an optional flag it allows the user more flexibility. To support this, add a --force-sync flag to the sync command that will attempt to overwrite the existing git dir if it is specified and the existing git dir points to the wrong obj dir. Change-Id: Ieddda8ad54e264a1eb4a9d54881dd6ebc8a03833
* Merge "InitGitDir: Clean up created directories"Conley Owens2015-07-291-51/+63
|\
| * InitGitDir: Clean up created directoriesKevin Degi2015-07-271-51/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | If _InitGitDir fails, it leaves any progress it had made on the file system. This can cause subsequent calls to repo sync to behave differently. This is especially evident when _CheckDirReference() fails, since it will not be invoked when sync is retried because both the source and destination directories already exist. To address this, have _InitGitDir() clean up any directories it has created if it catches an exception. Also behave the same way for _InitWorkTree(). Change-Id: Ic16bb3feea649e115b59bd44be294e89e3692aeb
* | Revert "Add --prune option to fetch when syncing a mirror repo"v1.12.24David Pursehouse2015-07-201-2/+0
|/ | | | | | | | | For some users it is not desirable to remove refs that don't exist on the remote server when syncing a mirror repo. This reverts commit b4d43b9f664d6472b6c1e91c98f951037d00cea5. Change-Id: Ie849b66682138ef88da6cd1a5fbb27e993197dd7
* Merge "Fail if gitdir does not point to objdir during sync"Conley Owens2015-07-151-20/+47
|\
| * Fail if gitdir does not point to objdir during syncKevin Degi2015-05-121-20/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are a set of cases that can cause the git directory in .repo/projects to point to a directory in .repo/project-objects that is not the one specified in the manifest. This results in a tree that is not sane, and so should cause a failure. In order to reproduce the failure case: 1) Sync to any manifest 2) Change the 'name' of a project to a different repository. Leave the 'path' the same. 3) Resync the modified project. The project-objects directory will not be created, and the projects directory will remain pointed at the old project-objects. Change-Id: Ie6711b1c773508850c5c9f748a27ff72d65e2bf2
* | project.RemoteFetch: Handle depth cases more robustlyKevin Degi2015-07-151-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The fetch logic for the case where depth is set and revision is a SHA1 has several failure modes that are not handled well by the current logic. 1) 'git fetch <SHA1>' requires git version >= 1.8.3 2) 'git fetch <SHA1>' can be prevented by a configuration option on the server. 3) 'git fetch --depth=<N> <refspec>' can fail to contain a SHA1 specified by the manifest. Each of these cases cause infinite recursion when _RemoteFetch() tries to call itself with current_branch_only=False because current_branch_only is set to True when depth != None. To try to prevent the infinite recursion, we set self.clone_depth to None before the first retry of _RemoteFetch(). This will allow the Fetch to eventually succeed in the case where clone-depth is specified in the manifest. A user specified depth from the init command will still recurse infinitely. In addition, never try to fetch a SHA1 directly if the git version being used is not at least 1.8.3. Change-Id: I802fc17878c0929cfd63fff611633c1d3b54ecd3
* | Teach _LinkFile._Link to handle globs.Wink Saville2015-06-031-11/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows a project to use globs in the linkfile src attribute. When a glob is used in the src the dest field must be a directory. Then _LinkFile._Link(self) calls will create symbolic links in the dest directory to all of the entries in the src as defined by the glob specification. Below all of the entries in master-configs/ will have symbolic links in <root dir>/configs directory: <project name="helloworld.git" path="apps/helloworld"> <linkfile src="master-configs/*" dest="configs"/> </project> Change-Id: Idfed8fa47c83d2ca6e2b8e867731b8e2f9e2eb47
* | Merge changes I32da12c2,Ie4a65b3eDavid Pursehouse2015-06-021-0/+3
|\ \ | | | | | | | | | | | | | | | * changes: Skip sleep and retry if git remote update exits with a signal Catch exceptions in project list generator
| * | Skip sleep and retry if git remote update exits with a signalColin Cross2015-05-131-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | Pressing ctrl-c during repo sync often hangs for 30 to 45 seconds due to the time.sleep and retry in _RemoteFetch. If git exits with a signal, for example -2 for SIGINT triggered by ctrl-c, skip the sleep and retry. Change-Id: I32da12c2dcc96d9cc0b12a066e824b12ebfb52a0
* | | Make linkfile symlinks relativeColin Cross2015-06-011-6/+7
|/ / | | | | | | | | | | | | | | | | | | | | The source (target) of the symlink is specified relative to a project within a tree, and the destination is specified relative to the top of the tree, so it should always be possible to create a relative symlink to the target file. Relative symlinks will allow moving an entire tree without breaking the symlink, and copying a tree (with -p) without leaving a symlink to the old tree. Change-Id: I16492a8b59a137d2abe43ca78e3b212e2c835599
* | Merge "Don't attempt to create "fully qualified names" for SHA1s"David Pursehouse2015-05-111-1/+1
|\ \
| * | Don't attempt to create "fully qualified names" for SHA1sAlexandre Boeglin2015-04-301-1/+1
| |/ | | | | | | | | | | Doing so breaks "repo init -b <SHA1>". Change-Id: Ic071a1b099a9125db22ea446d7e92e7854d69b37
* | Merge "Add option on sync to avoid fetching from remotes for existing sha1"David Pursehouse2015-05-011-4/+10
|\ \
| * | Add option on sync to avoid fetching from remotes for existing sha1David Pursehouse2015-04-301-4/+10
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | In 2fb6466f795eb30c1dfa598501f5b5d2981e6a5f an optimisation was added to avoid fetching from remotes if the project is fixed to a revision and the revision is already available locally. This causes problems for users who expect all objects to be fetched by default. Change the logic so that the optimized behaviour is only enabled if an option is explicitly given to repo sync. Change-Id: I3b2794ddd8e0071b1787e166463cd8347ca9e24f
* / Add --prune option to fetch when syncing a mirror repoDavid Pursehouse2015-04-301-0/+2
|/ | | | | | | When syncing a mirror repo, add the --prune option to the fetch command to force removal of stale refs from the mirror. Change-Id: I4b43b2a5c86b9915627887c16f6569066f3ab978
* Don't append branch to fetch spec when syncing to a mirrorv1.12.21David Pursehouse2015-04-271-12/+13
| | | | | | | | | | | | | | | | | | | | | | | | Appending the branch to the fetch spec causes sync of a mirror to fail for projects that don't have an explicit revision specified, and don't have a branch of the same name as the default revision. For example, a manifest defining a default revision: <default revision="master"> having a project without an explicit revision: <project name="path/to/project"> and not having a branch named "master", will cause repo sync to fail for that project with the error: Couldn't find remote ref refs/heads/master Modify the logic to not append the branch onto the fetch spec when syncing to a mirror. Change-Id: I5c4457bd125519abf27abe682dea62ad708978c9